server: set registered only after configuring subscribers (#1557)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-04-21 23:01:59 +03:00 committed by GitHub
parent d7ecb58f6c
commit bea092f082
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 9 deletions

View File

@ -692,11 +692,6 @@ func (g *grpcServer) Register() error {
g.Lock()
defer g.Unlock()
if cacheService {
g.rsvc = service
}
g.registered = true
for sb := range g.subscribers {
handler := g.createSubHandler(sb, g.opts)
var opts []broker.SubscribeOption
@ -722,6 +717,11 @@ func (g *grpcServer) Register() error {
g.subscribers[sb] = []broker.Subscriber{sub}
}
g.registered = true
if cacheService {
g.rsvc = service
}
return nil
}

View File

@ -650,10 +650,6 @@ func (s *rpcServer) Register() error {
s.Lock()
defer s.Unlock()
if cacheService {
s.rsvc = service
}
s.registered = true
// set what we're advertising
s.opts.Advertise = addr
@ -693,6 +689,10 @@ func (s *rpcServer) Register() error {
}
s.subscribers[sb] = []broker.Subscriber{sub}
}
if cacheService {
s.rsvc = service
}
s.registered = true
return nil
}