mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
模块支持rpc调用
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/duanhf2012/origin/event"
|
"github.com/duanhf2012/origin/event"
|
||||||
"github.com/duanhf2012/origin/log"
|
"github.com/duanhf2012/origin/log"
|
||||||
|
rpcHandle "github.com/duanhf2012/origin/rpc"
|
||||||
"github.com/duanhf2012/origin/util/timer"
|
"github.com/duanhf2012/origin/util/timer"
|
||||||
"reflect"
|
"reflect"
|
||||||
"time"
|
"time"
|
||||||
@@ -31,6 +32,7 @@ type IModule interface {
|
|||||||
//1.管理各模块树层关系
|
//1.管理各模块树层关系
|
||||||
//2.提供定时器常用工具
|
//2.提供定时器常用工具
|
||||||
type Module struct {
|
type Module struct {
|
||||||
|
rpcHandle.IRpcHandler
|
||||||
moduleId int64 //模块Id
|
moduleId int64 //模块Id
|
||||||
moduleName string //模块名称
|
moduleName string //模块名称
|
||||||
parent IModule //父亲
|
parent IModule //父亲
|
||||||
@@ -86,7 +88,7 @@ func (m *Module) AddModule(module IModule) (int64,error){
|
|||||||
if ok == true {
|
if ok == true {
|
||||||
return 0,fmt.Errorf("Exists module id %d",module.GetModuleId())
|
return 0,fmt.Errorf("Exists module id %d",module.GetModuleId())
|
||||||
}
|
}
|
||||||
|
pAddModule.IRpcHandler = m.IRpcHandler
|
||||||
pAddModule.self = module
|
pAddModule.self = module
|
||||||
pAddModule.parent = m.self
|
pAddModule.parent = m.self
|
||||||
pAddModule.dispatcher = m.GetAncestor().getBaseModule().(*Module).dispatcher
|
pAddModule.dispatcher = m.GetAncestor().getBaseModule().(*Module).dispatcher
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ type IService interface {
|
|||||||
|
|
||||||
type Service struct {
|
type Service struct {
|
||||||
Module
|
Module
|
||||||
rpc.RpcHandler //rpc
|
rpcHandler rpc.RpcHandler //rpc
|
||||||
name string //service name
|
name string //service name
|
||||||
wg sync.WaitGroup
|
wg sync.WaitGroup
|
||||||
serviceCfg interface{}
|
serviceCfg interface{}
|
||||||
@@ -60,7 +60,8 @@ func (s *Service) OpenProfiler() {
|
|||||||
func (s *Service) Init(iService IService,getClientFun rpc.FuncRpcClient,getServerFun rpc.FuncRpcServer,serviceCfg interface{}) {
|
func (s *Service) Init(iService IService,getClientFun rpc.FuncRpcClient,getServerFun rpc.FuncRpcServer,serviceCfg interface{}) {
|
||||||
s.dispatcher =timer.NewDispatcher(timerDispatcherLen)
|
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.self = iService.(IModule)
|
||||||
//初始化祖先
|
//初始化祖先
|
||||||
s.ancestor = iService.(IModule)
|
s.ancestor = iService.(IModule)
|
||||||
|
|||||||
Reference in New Issue
Block a user