ing
This commit is contained in:
parent
665b0bbd56
commit
f76a10dcd1
|
@ -2,4 +2,6 @@ package container
|
|||
|
||||
const (
|
||||
CONTAINER_CRAWLERS = "CONTAINER_CRAWLERS"
|
||||
CONTAINER_RPC_CLIENT_CODEC = "CONTAINER_RPC_CLIENT_CODEC"
|
||||
CONTAINER_RPC_WRITE_CHAN = "CONTAINER_RPC_WRITE_CHAN"
|
||||
)
|
||||
|
|
|
@ -5,6 +5,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"
|
||||
|
||||
// For annotation
|
||||
_ "git.loafle.net/overflow/commons-go/core/annotation"
|
||||
|
@ -18,6 +19,9 @@ func init() {
|
|||
|
||||
type ProbeService struct {
|
||||
cda.TypeAnnotation `annotation:"@overflow:RPCService()"`
|
||||
|
||||
RPCClientCodec crp.ClientCodec `annotation:"@Resource(name='CONTAINER_RPC_CLIENT_CODEC')"`
|
||||
RPCWriteChan chan<- []byte `annotation:"@Resource(name='CONTAINER_RPC_WRITE_CHAN')"`
|
||||
}
|
||||
|
||||
func (s *ProbeService) InitService() error {
|
||||
|
@ -38,6 +42,12 @@ func (s *ProbeService) DestroyService() {
|
|||
}
|
||||
|
||||
func (s *ProbeService) Send(method string, params ...interface{}) error {
|
||||
buf, err := s.RPCClientCodec.NewRequest(method, params, nil)
|
||||
if nil != err {
|
||||
return err
|
||||
}
|
||||
|
||||
s.RPCWriteChan <- buf
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ type RPCServlets struct {
|
|||
cssn.Servlets
|
||||
|
||||
RPCInvoker crr.RPCInvoker
|
||||
RPCWriteChan <-chan []byte
|
||||
}
|
||||
|
||||
func (s *RPCServlets) Handshake(servletCtx server.ServletCtx, conn net.Conn) error {
|
||||
|
@ -72,6 +73,8 @@ func (s *RPCServlets) Handle(servletCtx server.ServletCtx,
|
|||
}
|
||||
|
||||
writeChan <- replyBuff
|
||||
case buf := <-s.RPCWriteChan:
|
||||
writeChan <- buf
|
||||
case <-stopChan:
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user