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
|
return call
|
||||||
}
|
}
|
||||||
|
|
||||||
err = slf.conn.WriteMsg(bytes)
|
err = slf.conn.WriteMsg([]byte{uint8(processor.GetProcessorType())},bytes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
slf.RemovePending(call.Seq)
|
slf.RemovePending(call.Seq)
|
||||||
call.Err = err
|
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{
|
func (slf *JsonRpcRequestData) IsNoReply() bool{
|
||||||
return slf.NoReply
|
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{
|
func (slf *PBRpcRequestData) IsNoReply() bool{
|
||||||
return slf.GetNoReply()
|
return slf.GetNoReply()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ type IRpcProcessor interface {
|
|||||||
ReleaseRpcRequest(rpcRequestData IRpcRequestData)
|
ReleaseRpcRequest(rpcRequestData IRpcRequestData)
|
||||||
ReleaseRpcRespose(rpcRequestData IRpcResponseData)
|
ReleaseRpcRespose(rpcRequestData IRpcResponseData)
|
||||||
IsParse(param interface{}) bool //是否可解析
|
IsParse(param interface{}) bool //是否可解析
|
||||||
|
GetProcessorType() RpcProcessorType
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -108,8 +108,7 @@ func (agent *RpcAgent) WriteRespone(processor IRpcProcessor,serviceMethod string
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errM = agent.conn.WriteMsg([]byte{uint8(processor.GetProcessorType())},bytes)
|
||||||
errM = agent.conn.WriteMsg(bytes)
|
|
||||||
if errM != nil {
|
if errM != nil {
|
||||||
log.Error("Rpc %s return is error:%+v",serviceMethod,errM)
|
log.Error("Rpc %s return is error:%+v",serviceMethod,errM)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user