mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
优化原始rpc,采用register方式
This commit is contained in:
@@ -12,11 +12,12 @@ type JsonProcessor struct {
|
||||
|
||||
type JsonRpcRequestData struct {
|
||||
//packhead
|
||||
Seq uint64 // sequence number chosen by client
|
||||
Seq uint64 // sequence number chosen by client
|
||||
rpcMethodId uint32
|
||||
ServiceMethod string // format: "Service.Method"
|
||||
NoReply bool //是否需要返回
|
||||
NoReply bool //是否需要返回
|
||||
//packbody
|
||||
InParam []byte
|
||||
InParam []byte
|
||||
}
|
||||
|
||||
type JsonRpcResponseData struct {
|
||||
@@ -49,9 +50,10 @@ func (jsonProcessor *JsonProcessor) Unmarshal(data []byte, v interface{}) error{
|
||||
return json.Unmarshal(data,v)
|
||||
}
|
||||
|
||||
func (jsonProcessor *JsonProcessor) MakeRpcRequest(seq uint64,serviceMethod string,noReply bool,inParam []byte) IRpcRequestData{
|
||||
func (jsonProcessor *JsonProcessor) MakeRpcRequest(seq uint64,rpcMethodId uint32,serviceMethod string,noReply bool,inParam []byte) IRpcRequestData{
|
||||
jsonRpcRequestData := rpcJsonRequestDataPool.Get().(*JsonRpcRequestData)
|
||||
jsonRpcRequestData.Seq = seq
|
||||
jsonRpcRequestData.rpcMethodId = rpcMethodId
|
||||
jsonRpcRequestData.ServiceMethod = serviceMethod
|
||||
jsonRpcRequestData.NoReply = noReply
|
||||
jsonRpcRequestData.InParam = inParam
|
||||
@@ -92,6 +94,10 @@ func (jsonRpcRequestData *JsonRpcRequestData) GetSeq() uint64{
|
||||
return jsonRpcRequestData.Seq
|
||||
}
|
||||
|
||||
func (jsonRpcRequestData *JsonRpcRequestData) GetRpcMethodId() uint32{
|
||||
return jsonRpcRequestData.rpcMethodId
|
||||
}
|
||||
|
||||
func (jsonRpcRequestData *JsonRpcRequestData) GetServiceMethod() string{
|
||||
return jsonRpcRequestData.ServiceMethod
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user