Skip to content

Commit 68da9aa

Browse files
jsvisafjl
authored andcommitted
rpc: clean up check for missing methods/subscriptions on handler (#17145)
1 parent fe6a947 commit 68da9aa

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

‎rpc/server.go‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error {
9494

9595
methods, subscriptions := suitableCallbacks(rcvrVal, svc.typ)
9696

97-
// already a previous service register under given sname, merge methods/subscriptions
97+
if len(methods) == 0 && len(subscriptions) == 0 {
98+
return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
99+
}
100+
101+
// already a previous service register under given name, merge methods/subscriptions
98102
if regsvc, present := s.services[name]; present {
99-
if len(methods) == 0 && len(subscriptions) == 0 {
100-
return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
101-
}
102103
for _, m := range methods {
103104
regsvc.callbacks[formatName(m.method.Name)] = m
104105
}
@@ -111,10 +112,6 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error {
111112
svc.name = name
112113
svc.callbacks, svc.subscriptions = methods, subscriptions
113114

114-
if len(svc.callbacks) == 0 && len(svc.subscriptions) == 0 {
115-
return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr)
116-
}
117-
118115
s.services[svc.name] = svc
119116
return nil
120117
}

0 commit comments

Comments
 (0)