mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-04 06:54:45 +08:00
减少字符串拼接-gc优化
This commit is contained in:
@@ -371,13 +371,12 @@ func (handler *RpcHandler) goRpc(processor IRpcProcessor,bCast bool,nodeId int,s
|
||||
continue
|
||||
}
|
||||
serviceName := serviceMethod[:findIndex]
|
||||
method := serviceMethod[findIndex+1:]
|
||||
if serviceName == handler.rpcHandler.GetName() { //自己服务调用
|
||||
//调用自己rpcHandler处理器
|
||||
return pLocalRpcServer.myselfRpcHandlerGo(serviceName,method,args,nil)
|
||||
return pLocalRpcServer.myselfRpcHandlerGo(serviceName,serviceMethod,args,nil)
|
||||
}
|
||||
//其他的rpcHandler的处理器
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(processor,pClientList[i],true,serviceName,method,args,nil,nil)
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(processor,pClientList[i],true,serviceName,serviceMethod,args,nil,nil)
|
||||
if pCall.Err!=nil {
|
||||
err = pCall.Err
|
||||
}
|
||||
@@ -421,13 +420,12 @@ func (handler *RpcHandler) callRpc(nodeId int,serviceMethod string,args interfac
|
||||
return err
|
||||
}
|
||||
serviceName := serviceMethod[:findIndex]
|
||||
method := serviceMethod[findIndex+1:]
|
||||
if serviceName == handler.rpcHandler.GetName() { //自己服务调用
|
||||
//调用自己rpcHandler处理器
|
||||
return pLocalRpcServer.myselfRpcHandlerGo(serviceName,method,args,reply)
|
||||
return pLocalRpcServer.myselfRpcHandlerGo(serviceName,serviceMethod,args,reply)
|
||||
}
|
||||
//其他的rpcHandler的处理器
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(nil,pClient,false,serviceName,method,args,reply,nil)
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(nil,pClient,false,serviceName,serviceMethod,args,reply,nil)
|
||||
err = pCall.Done().Err
|
||||
pClient.RemovePending(pCall.Seq)
|
||||
ReleaseCall(pCall)
|
||||
@@ -495,10 +493,9 @@ func (handler *RpcHandler) asyncCallRpc(nodeid int,serviceMethod string,args int
|
||||
return nil
|
||||
}
|
||||
serviceName := serviceMethod[:findIndex]
|
||||
method := serviceMethod[findIndex+1:]
|
||||
//调用自己rpcHandler处理器
|
||||
if serviceName == handler.rpcHandler.GetName() { //自己服务调用
|
||||
err := pLocalRpcServer.myselfRpcHandlerGo(serviceName,method,args,reply)
|
||||
err := pLocalRpcServer.myselfRpcHandlerGo(serviceName,serviceMethod,args,reply)
|
||||
if err == nil {
|
||||
fVal.Call([]reflect.Value{reflect.ValueOf(reply),NilError})
|
||||
}else{
|
||||
@@ -508,13 +505,13 @@ func (handler *RpcHandler) asyncCallRpc(nodeid int,serviceMethod string,args int
|
||||
|
||||
//其他的rpcHandler的处理器
|
||||
if callback!=nil {
|
||||
err = pLocalRpcServer.selfNodeRpcHandlerAsyncGo(pClient, handler,false,serviceName,method,args,reply,fVal)
|
||||
err = pLocalRpcServer.selfNodeRpcHandlerAsyncGo(pClient, handler,false,serviceName,serviceMethod,args,reply,fVal)
|
||||
if err != nil {
|
||||
fVal.Call([]reflect.Value{reflect.ValueOf(reply),reflect.ValueOf(err)})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(nil,pClient,false,serviceName,method,args,reply,nil)
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(nil,pClient,false,serviceName,serviceMethod,args,reply,nil)
|
||||
err = pCall.Done().Err
|
||||
pClient.RemovePending(pCall.Seq)
|
||||
ReleaseCall(pCall)
|
||||
@@ -585,7 +582,6 @@ func (handler *RpcHandler) RawGoNode(rpcProcessorType RpcProcessorType,nodeId in
|
||||
//2.rpcclient调用
|
||||
//如果调用本结点服务
|
||||
for i:=0;i<count;i++{
|
||||
//for _,pClient := range pClientList {
|
||||
if pClientList[i].bSelfNode == true {
|
||||
pLocalRpcServer:= handler.funcRpcServer()
|
||||
//判断是否是同一服务
|
||||
@@ -599,16 +595,15 @@ func (handler *RpcHandler) RawGoNode(rpcProcessorType RpcProcessorType,nodeId in
|
||||
continue
|
||||
}
|
||||
serviceName := serviceMethod[:findIndex]
|
||||
method := serviceMethod[findIndex+1:]
|
||||
//调用自己rpcHandler处理器
|
||||
if serviceName == handler.rpcHandler.GetName() { //自己服务调用
|
||||
err:= pLocalRpcServer.myselfRpcHandlerGo(serviceName,method,args,nil)
|
||||
err:= pLocalRpcServer.myselfRpcHandlerGo(serviceName,serviceMethod,args,nil)
|
||||
args.DoGc()
|
||||
return err
|
||||
}
|
||||
|
||||
//其他的rpcHandler的处理器
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(processor,pClientList[i],true,serviceName,method,nil,nil,args)
|
||||
pCall := pLocalRpcServer.selfNodeRpcHandlerGo(processor,pClientList[i],true,serviceName,serviceMethod,nil,nil,args)
|
||||
if pCall.Err!=nil {
|
||||
err = pCall.Err
|
||||
}
|
||||
|
||||
@@ -220,19 +220,19 @@ func (server *Server) NewAgent(c *network.TCPConn) network.Agent {
|
||||
return agent
|
||||
}
|
||||
|
||||
func (server *Server) myselfRpcHandlerGo(handlerName string,methodName string, args interface{},reply interface{}) error {
|
||||
func (server *Server) myselfRpcHandlerGo(handlerName string,serviceMethod string, args interface{},reply interface{}) error {
|
||||
rpcHandler := server.rpcHandleFinder.FindRpcHandler(handlerName)
|
||||
if rpcHandler== nil {
|
||||
err := fmt.Errorf("service method %s.%s not config!", handlerName,methodName)
|
||||
err := fmt.Errorf("service method %s not config!", serviceMethod)
|
||||
log.Error("%s",err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
return rpcHandler.CallMethod(fmt.Sprintf("%s.%s",handlerName,methodName),args,reply)
|
||||
return rpcHandler.CallMethod(serviceMethod,args,reply)
|
||||
}
|
||||
|
||||
|
||||
func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor,client *Client,noReply bool,handlerName string,methodName string, args interface{},reply interface{},inputArgs IRawInputArgs) *Call {
|
||||
func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor,client *Client,noReply bool,handlerName string,serviceMethod string, args interface{},reply interface{},inputArgs IRawInputArgs) *Call {
|
||||
pCall := MakeCall()
|
||||
pCall.Seq = client.generateSeq()
|
||||
|
||||
@@ -241,7 +241,7 @@ func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor,client *Clien
|
||||
if inputArgs!= nil {
|
||||
inputArgs.DoGc()
|
||||
}
|
||||
pCall.Err = fmt.Errorf("service method %s.%s not config!", handlerName,methodName)
|
||||
pCall.Err = fmt.Errorf("service method %s not config!", serviceMethod)
|
||||
log.Error("%s",pCall.Err.Error())
|
||||
pCall.done <- pCall
|
||||
return pCall
|
||||
@@ -259,7 +259,8 @@ func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor,client *Clien
|
||||
if inputArgs!=nil {
|
||||
additionParam = inputArgs.GetAdditionParam()
|
||||
}
|
||||
req.RpcRequestData = processor.MakeRpcRequest(0,fmt.Sprintf("%s.%s",handlerName,methodName),noReply,nil,additionParam)
|
||||
|
||||
req.RpcRequestData = processor.MakeRpcRequest(0, serviceMethod,noReply,nil,additionParam)
|
||||
req.rpcProcessor = processor
|
||||
if noReply == false {
|
||||
client.AddPending(pCall)
|
||||
@@ -292,7 +293,7 @@ func (server *Server) selfNodeRpcHandlerGo(processor IRpcProcessor,client *Clien
|
||||
return pCall
|
||||
}
|
||||
|
||||
func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client,callerRpcHandler IRpcHandler,noReply bool,handlerName string,methodName string,args interface{},reply interface{},callback reflect.Value) error {
|
||||
func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client,callerRpcHandler IRpcHandler,noReply bool,handlerName string,serviceMethod string,args interface{},reply interface{},callback reflect.Value) error {
|
||||
pCall := MakeCall()
|
||||
pCall.Seq = client.generateSeq()
|
||||
pCall.rpcHandler = callerRpcHandler
|
||||
@@ -300,7 +301,7 @@ func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client,callerRpcHandler
|
||||
pCall.Reply = reply
|
||||
rpcHandler := server.rpcHandleFinder.FindRpcHandler(handlerName)
|
||||
if rpcHandler== nil {
|
||||
err := fmt.Errorf("service method %s.%s not config!", handlerName,methodName)
|
||||
err := fmt.Errorf("service method %s not config!", serviceMethod)
|
||||
log.Error("%+v",err)
|
||||
ReleaseCall(pCall)
|
||||
return err
|
||||
@@ -312,7 +313,7 @@ func (server *Server) selfNodeRpcHandlerAsyncGo(client *Client,callerRpcHandler
|
||||
req.bLocalRequest = true
|
||||
_,processor := GetProcessorType(args)
|
||||
req.rpcProcessor =processor
|
||||
req.RpcRequestData = processor.MakeRpcRequest(0,fmt.Sprintf("%s.%s",handlerName,methodName),noReply,nil,nil)
|
||||
req.RpcRequestData = processor.MakeRpcRequest(0,serviceMethod,noReply,nil,nil)
|
||||
if noReply == false {
|
||||
client.AddPending(pCall)
|
||||
req.requestHandle = func(Returns interface{},Err *RpcError){
|
||||
|
||||
Reference in New Issue
Block a user