diff --git a/registry/rpc_registry.go b/registry/rpc_registry.go index 4c4595f..577198d 100644 --- a/registry/rpc_registry.go +++ b/registry/rpc_registry.go @@ -17,6 +17,8 @@ type RPCRegistry interface { RPCInvoker GetService(name string) interface{} RegisterService(receiver interface{}, name string) error + RegisterServices(receivers ...interface{}) error + RegisterServiceMap(keysAndValues map[string]interface{}) error } // RPCRegistry serves registered RPC services using registered codecs. @@ -44,6 +46,32 @@ func (rr *rpcRegistry) RegisterService(receiver interface{}, name string) error return rr.services.register(receiver, name) } +func (rr *rpcRegistry) RegisterServices(receivers ...interface{}) error { + if nil == receivers || 0 == len(receivers) { + return nil + } + + for _, receiver := range receivers { + if err := rr.services.register(receiver, ""); nil != err { + return err + } + } + return nil +} + +func (rr *rpcRegistry) RegisterServiceMap(keysAndValues map[string]interface{}) error { + if nil == keysAndValues || 0 == len(keysAndValues) { + return nil + } + + for name, receiver := range keysAndValues { + if err := rr.services.register(receiver, name); nil != err { + return err + } + } + return nil +} + func (rr *rpcRegistry) GetService(name string) interface{} { return rr.services.getService(name) }