diff options
author | Wenbiao Zheng <delweng@gmail.com> | 2018-07-24 08:00:55 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2018-07-24 08:00:55 +0800 |
commit | 68da9aa71638b4ae7a91d61b815a00b4e9be09d4 (patch) | |
tree | 7fe3bbec088f924ce54d9205a94a701211cd4549 | |
parent | fe6a9473dc49b4cc17f3c9d2f63d409ab878bce1 (diff) | |
download | go-tangerine-68da9aa71638b4ae7a91d61b815a00b4e9be09d4.tar go-tangerine-68da9aa71638b4ae7a91d61b815a00b4e9be09d4.tar.gz go-tangerine-68da9aa71638b4ae7a91d61b815a00b4e9be09d4.tar.bz2 go-tangerine-68da9aa71638b4ae7a91d61b815a00b4e9be09d4.tar.lz go-tangerine-68da9aa71638b4ae7a91d61b815a00b4e9be09d4.tar.xz go-tangerine-68da9aa71638b4ae7a91d61b815a00b4e9be09d4.tar.zst go-tangerine-68da9aa71638b4ae7a91d61b815a00b4e9be09d4.zip |
rpc: clean up check for missing methods/subscriptions on handler (#17145)
-rw-r--r-- | rpc/server.go | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/rpc/server.go b/rpc/server.go index 90ffadd25..214e1d3ed 100644 --- a/rpc/server.go +++ b/rpc/server.go @@ -94,11 +94,12 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error { methods, subscriptions := suitableCallbacks(rcvrVal, svc.typ) - // already a previous service register under given sname, merge methods/subscriptions + if len(methods) == 0 && len(subscriptions) == 0 { + return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr) + } + + // already a previous service register under given name, merge methods/subscriptions if regsvc, present := s.services[name]; present { - if len(methods) == 0 && len(subscriptions) == 0 { - return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr) - } for _, m := range methods { regsvc.callbacks[formatName(m.method.Name)] = m } @@ -111,10 +112,6 @@ func (s *Server) RegisterName(name string, rcvr interface{}) error { svc.name = name svc.callbacks, svc.subscriptions = methods, subscriptions - if len(svc.callbacks) == 0 && len(svc.subscriptions) == 0 { - return fmt.Errorf("Service %T doesn't have any suitable methods/subscriptions to expose", rcvr) - } - s.services[svc.name] = svc return nil } |