From 8da32be2568cdc23ce0141ecbb443232e7280f0c Mon Sep 17 00:00:00 2001 From: boyce Date: Fri, 18 Dec 2020 16:36:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A8=A1=E5=9D=97=E6=94=AF=E6=8C=81rpc?= =?UTF-8?q?=E8=B0=83=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- service/module.go | 4 +++- service/service.go | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/service/module.go b/service/module.go index 5b6faae..9fc38bb 100644 --- a/service/module.go +++ b/service/module.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/duanhf2012/origin/event" "github.com/duanhf2012/origin/log" + rpcHandle "github.com/duanhf2012/origin/rpc" "github.com/duanhf2012/origin/util/timer" "reflect" "time" @@ -31,6 +32,7 @@ type IModule interface { //1.管理各模块树层关系 //2.提供定时器常用工具 type Module struct { + rpcHandle.IRpcHandler moduleId int64 //模块Id moduleName string //模块名称 parent IModule //父亲 @@ -86,7 +88,7 @@ func (m *Module) AddModule(module IModule) (int64,error){ if ok == true { return 0,fmt.Errorf("Exists module id %d",module.GetModuleId()) } - + pAddModule.IRpcHandler = m.IRpcHandler pAddModule.self = module pAddModule.parent = m.self pAddModule.dispatcher = m.GetAncestor().getBaseModule().(*Module).dispatcher diff --git a/service/service.go b/service/service.go index ff45f33..130a2ca 100644 --- a/service/service.go +++ b/service/service.go @@ -34,7 +34,7 @@ type IService interface { type Service struct { Module - rpc.RpcHandler //rpc + rpcHandler rpc.RpcHandler //rpc name string //service name wg sync.WaitGroup serviceCfg interface{} @@ -60,7 +60,8 @@ func (s *Service) OpenProfiler() { func (s *Service) Init(iService IService,getClientFun rpc.FuncRpcClient,getServerFun rpc.FuncRpcServer,serviceCfg interface{}) { s.dispatcher =timer.NewDispatcher(timerDispatcherLen) - s.InitRpcHandler(iService.(rpc.IRpcHandler),getClientFun,getServerFun) + s.rpcHandler.InitRpcHandler(iService.(rpc.IRpcHandler),getClientFun,getServerFun) + s.IRpcHandler = s s.self = iService.(IModule) //初始化祖先 s.ancestor = iService.(IModule)