Naming changes

This commit is contained in:
Ben Toogood 2020-05-13 13:38:13 +01:00
parent e5c1fbc591
commit 25c937fd0e
2 changed files with 14 additions and 14 deletions

View File

@ -22,8 +22,8 @@ type serviceRegistry struct {
name string name string
// address // address
address []string address []string
// registry is the proto client // client to call registry
registry pb.RegistryService client pb.RegistryService
} }
func (s *serviceRegistry) callOpts() []client.CallOption { func (s *serviceRegistry) callOpts() []client.CallOption {
@ -55,7 +55,7 @@ func (s *serviceRegistry) Init(opts ...registry.Option) error {
cli = grpc.NewClient() cli = grpc.NewClient()
} }
s.registry = pb.NewRegistryService(DefaultService, cli) s.client = pb.NewRegistryService(DefaultService, cli)
return nil return nil
} }
@ -78,7 +78,7 @@ func (s *serviceRegistry) Register(srv *registry.Service, opts ...registry.Regis
pbSrv.Options.Ttl = int64(options.TTL.Seconds()) pbSrv.Options.Ttl = int64(options.TTL.Seconds())
// register the service // register the service
_, err := s.registry.Register(options.Context, pbSrv, s.callOpts()...) _, err := s.client.Register(options.Context, pbSrv, s.callOpts()...)
if err != nil { if err != nil {
return err return err
} }
@ -96,7 +96,7 @@ func (s *serviceRegistry) Deregister(srv *registry.Service, opts ...registry.Der
} }
// deregister the service // deregister the service
_, err := s.registry.Deregister(options.Context, ToProto(srv), s.callOpts()...) _, err := s.client.Deregister(options.Context, ToProto(srv), s.callOpts()...)
if err != nil { if err != nil {
return err return err
} }
@ -112,7 +112,7 @@ func (s *serviceRegistry) GetService(name string, opts ...registry.GetOption) ([
options.Context = context.TODO() options.Context = context.TODO()
} }
rsp, err := s.registry.GetService(options.Context, &pb.GetRequest{ rsp, err := s.client.GetService(options.Context, &pb.GetRequest{
Service: name, Service: name,
}, s.callOpts()...) }, s.callOpts()...)
@ -136,7 +136,7 @@ func (s *serviceRegistry) ListServices(opts ...registry.ListOption) ([]*registry
options.Context = context.TODO() options.Context = context.TODO()
} }
rsp, err := s.registry.ListServices(options.Context, &pb.ListRequest{}, s.callOpts()...) rsp, err := s.client.ListServices(options.Context, &pb.ListRequest{}, s.callOpts()...)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -158,7 +158,7 @@ func (s *serviceRegistry) Watch(opts ...registry.WatchOption) (registry.Watcher,
options.Context = context.TODO() options.Context = context.TODO()
} }
stream, err := s.registry.Watch(options.Context, &pb.WatchRequest{ stream, err := s.client.Watch(options.Context, &pb.WatchRequest{
Service: options.Service, Service: options.Service,
}, s.callOpts()...) }, s.callOpts()...)
@ -205,6 +205,6 @@ func NewRegistry(opts ...registry.Option) registry.Registry {
opts: options, opts: options,
name: name, name: name,
address: addrs, address: addrs,
registry: pb.NewRegistryService(name, cli), client: pb.NewRegistryService(name, cli),
} }
} }

View File

@ -16,7 +16,7 @@ import (
"github.com/micro/go-micro/v2/debug/trace" "github.com/micro/go-micro/v2/debug/trace"
"github.com/micro/go-micro/v2/logger" "github.com/micro/go-micro/v2/logger"
"github.com/micro/go-micro/v2/plugin" "github.com/micro/go-micro/v2/plugin"
srvRegistry "github.com/micro/go-micro/v2/registry/service" registrySrv "github.com/micro/go-micro/v2/registry/service"
"github.com/micro/go-micro/v2/runtime" "github.com/micro/go-micro/v2/runtime"
"github.com/micro/go-micro/v2/server" "github.com/micro/go-micro/v2/server"
"github.com/micro/go-micro/v2/store" "github.com/micro/go-micro/v2/store"
@ -118,7 +118,7 @@ func (s *service) Init(opts ...Option) {
// Set the client for the micro clients // Set the client for the micro clients
s.opts.Auth.Init(auth.WithClient(s.Client())) s.opts.Auth.Init(auth.WithClient(s.Client()))
s.opts.Registry.Init(srvRegistry.WithClient(s.Client())) s.opts.Registry.Init(registrySrv.WithClient(s.Client()))
s.opts.Runtime.Init(runtime.WithClient(s.Client())) s.opts.Runtime.Init(runtime.WithClient(s.Client()))
s.opts.Store.Init(store.WithClient(s.Client())) s.opts.Store.Init(store.WithClient(s.Client()))
}) })