From e107b6b20756bdebd495dd80a15dcc1774c3b2d6 Mon Sep 17 00:00:00 2001 From: crusader Date: Thu, 3 May 2018 17:40:02 +0900 Subject: [PATCH] ing --- client/client.go | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/client/client.go b/client/client.go index afb07ac..71efe65 100644 --- a/client/client.go +++ b/client/client.go @@ -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 }