mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
修复RPC同时兼容json与pb的一些bug
This commit is contained in:
@@ -226,7 +226,7 @@ func (slf *Client) RawGo(processor IRpcProcessor,noReply bool,serviceMethod stri
|
||||
return call
|
||||
}
|
||||
|
||||
err = slf.conn.WriteMsg(bytes)
|
||||
err = slf.conn.WriteMsg([]byte{uint8(processor.GetProcessorType())},bytes)
|
||||
if err != nil {
|
||||
slf.RemovePending(call.Seq)
|
||||
call.Err = err
|
||||
|
||||
@@ -87,6 +87,11 @@ func (slf *JsonProcessor) IsParse(param interface{}) bool {
|
||||
}
|
||||
|
||||
|
||||
func (slf *JsonProcessor) GetProcessorType() RpcProcessorType{
|
||||
return RPC_PROCESSOR_JSON
|
||||
}
|
||||
|
||||
|
||||
func (slf *JsonRpcRequestData) IsNoReply() bool{
|
||||
return slf.NoReply
|
||||
}
|
||||
@@ -132,5 +137,3 @@ func (slf *JsonRpcResponseData) GetReply() []byte{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -134,6 +134,11 @@ func (slf *PBProcessor) IsParse(param interface{}) bool {
|
||||
}
|
||||
|
||||
|
||||
func (slf *PBProcessor) GetProcessorType() RpcProcessorType{
|
||||
return RPC_PROCESSOR_PB
|
||||
}
|
||||
|
||||
|
||||
func (slf *PBRpcRequestData) IsNoReply() bool{
|
||||
return slf.GetNoReply()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ type IRpcProcessor interface {
|
||||
ReleaseRpcRequest(rpcRequestData IRpcRequestData)
|
||||
ReleaseRpcRespose(rpcRequestData IRpcResponseData)
|
||||
IsParse(param interface{}) bool //是否可解析
|
||||
GetProcessorType() RpcProcessorType
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -108,8 +108,7 @@ func (agent *RpcAgent) WriteRespone(processor IRpcProcessor,serviceMethod string
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
errM = agent.conn.WriteMsg(bytes)
|
||||
errM = agent.conn.WriteMsg([]byte{uint8(processor.GetProcessorType())},bytes)
|
||||
if errM != nil {
|
||||
log.Error("Rpc %s return is error:%+v",serviceMethod,errM)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user