1.支持动态服务发现功能

2.Service中支持对RPC结点连接或断开事件监听
This commit is contained in:
boyce
2021-04-29 17:18:13 +08:00
parent 63c2ac4c98
commit a60ad1cccf
16 changed files with 1797 additions and 158 deletions

View File

@@ -63,7 +63,7 @@ type RpcHandler struct {
callResponseCallBack chan *Call //异步返回的回调
}
type TriggerRpcEvent func(bConnect bool,nodeId int)
type TriggerRpcEvent func(bConnect bool,clientSeq uint32,nodeId int)
type IRpcListener interface {
OnRpcConnected(nodeId int)
OnRpcDisconnect(nodeId int)
@@ -467,6 +467,9 @@ func (handler *RpcHandler) asyncCallRpc(nodeid int,serviceMethod string,args int
var pClientList [maxClusterNode]*Client
err,count := handler.funcRpcClient(nodeid,serviceMethod,pClientList[:])
if count==0||err != nil {
if err == nil {
err = fmt.Errorf("cannot find rpcclient from nodeid %d serviceMethod %s",nodeid,serviceMethod)
}
fVal.Call([]reflect.Value{reflect.ValueOf(reply),reflect.ValueOf(err)})
log.Error("Call serviceMethod is error:%+v!",err)
return nil