From 0a377671271faabf75b092f985737d597633eebd Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sat, 18 Jan 2020 19:53:51 +0000 Subject: [PATCH] Fix service registration with registry service --- client/client.go | 8 +++----- defaults.go | 4 ++++ registry/service/service.go | 4 ++-- registry/service/util.go | 1 + server/server.go | 8 +++----- util/kubernetes/client/templates.go | 1 - 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/client/client.go b/client/client.go index 6d597342..b09ae3af 100644 --- a/client/client.go +++ b/client/client.go @@ -110,6 +110,9 @@ var ( DefaultPoolSize = 100 // DefaultPoolTTL sets the connection pool ttl DefaultPoolTTL = time.Minute + + // NewClient returns a new client + NewClient func(...Option) Client = newRpcClient ) // Makes a synchronous call to a service using the default client @@ -128,11 +131,6 @@ func NewMessage(topic string, payload interface{}, opts ...MessageOption) Messag return DefaultClient.NewMessage(topic, payload, opts...) } -// Creates a new client with the options passed in -func NewClient(opt ...Option) Client { - return newRpcClient(opt...) -} - // Creates a new request using the default client. Content Type will // be set to the default within options and use the appropriate codec func NewRequest(service, endpoint string, request interface{}, reqOpts ...RequestOption) Request { diff --git a/defaults.go b/defaults.go index 65844c23..1a83bcf0 100644 --- a/defaults.go +++ b/defaults.go @@ -19,6 +19,10 @@ func init() { // embedded nats server nats.LocalServer(), ) + // new client initialisation + client.NewClient = gcli.NewClient + // new server initialisation + server.NewServer = gsrv.NewServer // default client client.DefaultClient = gcli.NewClient() // default server diff --git a/registry/service/service.go b/registry/service/service.go index 86f1becc..5a70cee7 100644 --- a/registry/service/service.go +++ b/registry/service/service.go @@ -12,7 +12,7 @@ import ( var ( // The default service name - DefaultService = "go.micro.service" + DefaultService = "go.micro.registry" ) type serviceRegistry struct { @@ -128,7 +128,7 @@ func (s *serviceRegistry) Watch(opts ...registry.WatchOption) (registry.Watcher, } func (s *serviceRegistry) String() string { - return s.name + return "service" } // NewRegistry returns a new registry service client diff --git a/registry/service/util.go b/registry/service/util.go index ad74ce0c..76d8ea9d 100644 --- a/registry/service/util.go +++ b/registry/service/util.go @@ -82,6 +82,7 @@ func ToProto(s *registry.Service) *pb.Service { Metadata: s.Metadata, Endpoints: endpoints, Nodes: nodes, + Options: new(pb.Options), } } diff --git a/server/server.go b/server/server.go index 0fcc3436..8e2d8473 100644 --- a/server/server.go +++ b/server/server.go @@ -136,6 +136,9 @@ var ( DefaultRegisterCheck = func(context.Context) error { return nil } DefaultRegisterInterval = time.Second * 30 DefaultRegisterTTL = time.Minute + + // NewServer creates a new server + NewServer func(...Option) Server = newRpcServer ) // DefaultOptions returns config options for the default service @@ -151,11 +154,6 @@ func Init(opt ...Option) { DefaultServer.Init(opt...) } -// NewServer returns a new server with options passed in -func NewServer(opt ...Option) Server { - return newRpcServer(opt...) -} - // NewRouter returns a new router func NewRouter() *router { return newRpcRouter() diff --git a/util/kubernetes/client/templates.go b/util/kubernetes/client/templates.go index 7132c23c..12b5be7f 100644 --- a/util/kubernetes/client/templates.go +++ b/util/kubernetes/client/templates.go @@ -5,7 +5,6 @@ var templates = map[string]string{ "service": serviceTmpl, } - // stripped image pull policy always // imagePullPolicy: Always var deploymentTmpl = `