server: register in the services namespace (#1718)
This commit is contained in:
@@ -576,8 +576,12 @@ func (g *grpcServer) Register() error {
|
||||
var regErr error
|
||||
|
||||
for i := 0; i < 3; i++ {
|
||||
// set the ttl
|
||||
rOpts := []registry.RegisterOption{registry.RegisterTTL(config.RegisterTTL)}
|
||||
// set the ttl and namespace
|
||||
rOpts := []registry.RegisterOption{
|
||||
registry.RegisterTTL(config.RegisterTTL),
|
||||
registry.RegisterDomain(g.opts.Namespace),
|
||||
}
|
||||
|
||||
// attempt to register
|
||||
if err := config.Registry.Register(service, rOpts...); err != nil {
|
||||
// set the error
|
||||
|
@@ -26,6 +26,7 @@ type Options struct {
|
||||
Address string
|
||||
Advertise string
|
||||
Id string
|
||||
Namespace string
|
||||
Version string
|
||||
HdlrWrappers []HandlerWrapper
|
||||
SubWrappers []SubscriberWrapper
|
||||
@@ -106,6 +107,13 @@ func Name(n string) Option {
|
||||
}
|
||||
}
|
||||
|
||||
// Namespace to register handlers in
|
||||
func Namespace(n string) Option {
|
||||
return func(o *Options) {
|
||||
o.Namespace = n
|
||||
}
|
||||
}
|
||||
|
||||
// Unique server id
|
||||
func Id(id string) Option {
|
||||
return func(o *Options) {
|
||||
|
@@ -522,7 +522,10 @@ func (s *rpcServer) Register() error {
|
||||
|
||||
regFunc := func(service *registry.Service) error {
|
||||
// create registry options
|
||||
rOpts := []registry.RegisterOption{registry.RegisterTTL(config.RegisterTTL)}
|
||||
rOpts := []registry.RegisterOption{
|
||||
registry.RegisterTTL(config.RegisterTTL),
|
||||
registry.RegisterDomain(s.opts.Namespace),
|
||||
}
|
||||
|
||||
var regErr error
|
||||
|
||||
|
Reference in New Issue
Block a user