This commit is contained in:
crusader 2018-05-03 17:40:02 +09:00
parent ebee7e2d27
commit e107b6b207

View File

@ -15,21 +15,8 @@ import (
)
func New(portNumber int) *crc.Client {
rpcWriteChan := make(chan []byte, 256)
rpcClientCodec := crpj.NewClientCodec()
cdr.RegisterResource(container.CONTAINER_CRAWLERS, crawler.GetCrawlers())
cdr.RegisterResource(container.CONTAINER_RPC_WRITE_CHAN, rpcWriteChan)
cdr.RegisterResource(container.CONTAINER_RPC_CLIENT_CODEC, rpcClientCodec)
services, err := cdr.GetInstancesByAnnotationType(occa.RPCServiceAnnotationType)
if nil != err {
logging.Logger().Panic(err)
}
rpcRegistry := crr.NewRPCRegistry()
rpcRegistry.RegisterServices(services...)
connector, err := occ.NewConnector(occp.ContainerDiscovery, portNumber)
if nil != err {
logging.Logger().Panic(err)
@ -39,11 +26,25 @@ func New(portNumber int) *crc.Client {
ch.Name = occp.ContainerDiscovery.String()
ch.Connector = connector
ch.RPCCodec = rpcClientCodec
c := &crc.Client{
ClientHandler: ch,
}
cdr.RegisterResource(container.CONTAINER_CRAWLERS, crawler.GetCrawlers())
cdr.RegisterResource(container.CONTAINER_RPC_CLIENT, c)
services, err := cdr.GetInstancesByAnnotationType(occa.RPCServiceAnnotationType)
if nil != err {
logging.Logger().Panic(err)
}
rpcRegistry := crr.NewRPCRegistry()
rpcRegistry.RegisterServices(services...)
ch.RPCInvoker = rpcRegistry
ch.Services = services
ch.OrderedServices = service.OrderedServices
return &crc.Client{
ClientHandler: ch,
}
return c
}