diff --git a/registry/registry.go b/registry/registry.go index 748ed5549..584028551 100644 --- a/registry/registry.go +++ b/registry/registry.go @@ -10,8 +10,8 @@ type Registrar interface { Deregister(ctx context.Context, service *ServiceInstance) error } -// Discovery is service discovery. -type Discovery interface { +// Discoverer is service discovery. +type Discoverer interface { // Service return the service instances in memory according to the service name. Fetch(ctx context.Context, serviceName string) ([]*ServiceInstance, error) // Watch creates a watcher according to the service name. diff --git a/transport/grpc/client.go b/transport/grpc/client.go index 8f6131686..5330ab228 100644 --- a/transport/grpc/client.go +++ b/transport/grpc/client.go @@ -39,7 +39,7 @@ func WithMiddleware(m middleware.Middleware) ClientOption { } // WithDiscovery with client registry. -func WithDiscovery(r registry.Discovery) ClientOption { +func WithDiscovery(r registry.Discoverer) ClientOption { return func(o *clientOptions) { o.discovery = r } @@ -57,7 +57,7 @@ type clientOptions struct { endpoint string timeout time.Duration middleware middleware.Middleware - discovery registry.Discovery + discovery registry.Discoverer grpcOpts []grpc.DialOption } diff --git a/transport/grpc/resolver/discovery/builder.go b/transport/grpc/resolver/discovery/builder.go index 5d7b5c1d4..aa063a519 100644 --- a/transport/grpc/resolver/discovery/builder.go +++ b/transport/grpc/resolver/discovery/builder.go @@ -21,15 +21,15 @@ func WithLogger(logger log.Logger) Option { } type builder struct { - registry registry.Discovery - logger log.Logger + discoverer registry.Discoverer + logger log.Logger } // NewBuilder creates a builder which is used to factory registry resolvers. -func NewBuilder(r registry.Discovery, opts ...Option) resolver.Builder { +func NewBuilder(r registry.Discoverer, opts ...Option) resolver.Builder { b := &builder{ - registry: r, - logger: log.DefaultLogger, + discoverer: r, + logger: log.DefaultLogger, } for _, o := range opts { o(b) @@ -38,7 +38,7 @@ func NewBuilder(r registry.Discovery, opts ...Option) resolver.Builder { } func (d *builder) Build(target resolver.Target, cc resolver.ClientConn, opts resolver.BuildOptions) (resolver.Resolver, error) { - w, err := d.registry.Watch(context.Background(), target.Endpoint) + w, err := d.discoverer.Watch(context.Background(), target.Endpoint) if err != nil { return nil, err }