Fix service registration with registry service

This commit is contained in:
Asim Aslam 2020-01-18 19:53:51 +00:00
parent 31e195bac7
commit 0a37767127
6 changed files with 13 additions and 13 deletions

View File

@ -110,6 +110,9 @@ var (
DefaultPoolSize = 100 DefaultPoolSize = 100
// DefaultPoolTTL sets the connection pool ttl // DefaultPoolTTL sets the connection pool ttl
DefaultPoolTTL = time.Minute DefaultPoolTTL = time.Minute
// NewClient returns a new client
NewClient func(...Option) Client = newRpcClient
) )
// Makes a synchronous call to a service using the default client // 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...) 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 // Creates a new request using the default client. Content Type will
// be set to the default within options and use the appropriate codec // be set to the default within options and use the appropriate codec
func NewRequest(service, endpoint string, request interface{}, reqOpts ...RequestOption) Request { func NewRequest(service, endpoint string, request interface{}, reqOpts ...RequestOption) Request {

View File

@ -19,6 +19,10 @@ func init() {
// embedded nats server // embedded nats server
nats.LocalServer(), nats.LocalServer(),
) )
// new client initialisation
client.NewClient = gcli.NewClient
// new server initialisation
server.NewServer = gsrv.NewServer
// default client // default client
client.DefaultClient = gcli.NewClient() client.DefaultClient = gcli.NewClient()
// default server // default server

View File

@ -12,7 +12,7 @@ import (
var ( var (
// The default service name // The default service name
DefaultService = "go.micro.service" DefaultService = "go.micro.registry"
) )
type serviceRegistry struct { type serviceRegistry struct {
@ -128,7 +128,7 @@ func (s *serviceRegistry) Watch(opts ...registry.WatchOption) (registry.Watcher,
} }
func (s *serviceRegistry) String() string { func (s *serviceRegistry) String() string {
return s.name return "service"
} }
// NewRegistry returns a new registry service client // NewRegistry returns a new registry service client

View File

@ -82,6 +82,7 @@ func ToProto(s *registry.Service) *pb.Service {
Metadata: s.Metadata, Metadata: s.Metadata,
Endpoints: endpoints, Endpoints: endpoints,
Nodes: nodes, Nodes: nodes,
Options: new(pb.Options),
} }
} }

View File

@ -136,6 +136,9 @@ var (
DefaultRegisterCheck = func(context.Context) error { return nil } DefaultRegisterCheck = func(context.Context) error { return nil }
DefaultRegisterInterval = time.Second * 30 DefaultRegisterInterval = time.Second * 30
DefaultRegisterTTL = time.Minute DefaultRegisterTTL = time.Minute
// NewServer creates a new server
NewServer func(...Option) Server = newRpcServer
) )
// DefaultOptions returns config options for the default service // DefaultOptions returns config options for the default service
@ -151,11 +154,6 @@ func Init(opt ...Option) {
DefaultServer.Init(opt...) 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 // NewRouter returns a new router
func NewRouter() *router { func NewRouter() *router {
return newRpcRouter() return newRpcRouter()

View File

@ -5,7 +5,6 @@ var templates = map[string]string{
"service": serviceTmpl, "service": serviceTmpl,
} }
// stripped image pull policy always // stripped image pull policy always
// imagePullPolicy: Always // imagePullPolicy: Always
var deploymentTmpl = ` var deploymentTmpl = `