diff --git a/constants.go b/constants.go index 01e8ee1..a79d0d2 100644 --- a/constants.go +++ b/constants.go @@ -1,7 +1,6 @@ package container const ( - CONTAINER_CRAWLERS = "CONTAINER_CRAWLERS" - CONTAINER_RPC_WRITE_CHAN = "CONTAINER_RPC_WRITE_CHAN" - CONTAINER_RPC_CLIENT_CODEC = "CONTAINER_RPC_CLIENT_CODEC" + CONTAINER_CRAWLERS = "CONTAINER_CRAWLERS" + CONTAINER_RPC_CLIENT = "CONTAINER_RPC_CLIENT" ) diff --git a/service/ProbeService.go b/service/ProbeService.go index 0b01a14..d8b5565 100644 --- a/service/ProbeService.go +++ b/service/ProbeService.go @@ -6,7 +6,7 @@ import ( cda "git.loafle.net/commons/di-go/annotation" cdr "git.loafle.net/commons/di-go/registry" - crp "git.loafle.net/commons/rpc-go/protocol" + crc "git.loafle.net/commons/rpc-go/client" // For annotation _ "git.loafle.net/overflow/commons-go/core/annotation" @@ -21,16 +21,12 @@ func init() { type ProbeService struct { cda.TypeAnnotation `annotation:"@overflow:RPCService()"` - RPCWriteChan chan []byte `annotation:"@Resource(name='CONTAINER_RPC_WRITE_CHAN')"` - ClientCodec crp.ClientCodec `annotation:"@Resource(name='CONTAINER_RPC_CLIENT_CODEC')"` + RPCClient *crc.Client `annotation:"@Resource(name='CONTAINER_RPC_CLIENT')"` } func (s *ProbeService) InitService() error { - if nil == s.RPCWriteChan { - return fmt.Errorf("RPCWriteChan is not valid") - } - if nil == s.ClientCodec { - return fmt.Errorf("ClientCodec is not valid") + if nil == s.RPCClient { + return fmt.Errorf("RPCClient is not valid") } return nil @@ -50,16 +46,9 @@ func (s *ProbeService) DestroyService() { } func (s *ProbeService) Send(method string, params ...interface{}) error { - buff, err := s.ClientCodec.NewRequest(method, params, nil) - if nil != err { + if err := s.RPCClient.Send(method, params...); nil != err { return err } - select { - case s.RPCWriteChan <- buff: - default: - return fmt.Errorf("Cannot send notification method[%s] params[%v]", method, params) - } - return nil }