ing
This commit is contained in:
parent
23658adc4b
commit
13d627dd6a
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user