selector: use custom domain (#1760)
* util/wrapper: improve auth errors * client: add network call option * client/selector: add domain select option * client/grpc: pass network option to selector
This commit is contained in:
@@ -38,14 +38,26 @@ func (c *registrySelector) Options() Options {
|
||||
}
|
||||
|
||||
func (c *registrySelector) Select(service string, opts ...SelectOption) (Next, error) {
|
||||
sopts := SelectOptions{
|
||||
Strategy: c.so.Strategy,
|
||||
}
|
||||
|
||||
sopts := SelectOptions{Strategy: c.so.Strategy}
|
||||
for _, opt := range opts {
|
||||
opt(&sopts)
|
||||
}
|
||||
|
||||
// a specific domain was requested, only lookup the services in that domain
|
||||
if len(sopts.Domain) > 0 {
|
||||
services, err := c.rc.GetService(service, registry.GetDomain(sopts.Domain))
|
||||
if err != nil && err != registry.ErrNotFound {
|
||||
return nil, err
|
||||
}
|
||||
for _, filter := range sopts.Filters {
|
||||
services = filter(services)
|
||||
}
|
||||
if len(services) == 0 {
|
||||
return nil, ErrNoneAvailable
|
||||
}
|
||||
return sopts.Strategy(services), nil
|
||||
}
|
||||
|
||||
// get the service. Because the service could be running in the current or the default domain,
|
||||
// we call both. For example, go.micro.service.foo could be running in the services current domain,
|
||||
// however the runtime (go.micro.runtime) will always be run in the default domain.
|
||||
|
||||
Reference in New Issue
Block a user