29 lines
661 B
Go
29 lines
661 B
Go
|
package client
|
||
|
|
||
|
import (
|
||
|
crc "git.loafle.net/commons/rpc-go/client"
|
||
|
crpj "git.loafle.net/commons/rpc-go/protocol/json"
|
||
|
crr "git.loafle.net/commons/rpc-go/registry"
|
||
|
csc "git.loafle.net/commons/server-go/client"
|
||
|
)
|
||
|
|
||
|
func New(name string, connector csc.Connector, services []interface{}) *crc.Client {
|
||
|
codec := crpj.NewClientCodec()
|
||
|
|
||
|
var rpcRegistry crr.RPCRegistry
|
||
|
if nil != services && 0 < len(services) {
|
||
|
rpcRegistry = crr.NewRPCRegistry()
|
||
|
rpcRegistry.RegisterServices(services...)
|
||
|
}
|
||
|
|
||
|
ch := &ClientHandlers{}
|
||
|
ch.Name = name
|
||
|
ch.Connector = connector
|
||
|
ch.RPCCodec = codec
|
||
|
ch.RPCInvoker = rpcRegistry
|
||
|
|
||
|
return &crc.Client{
|
||
|
ClientHandler: ch,
|
||
|
}
|
||
|
}
|