Documentation
¶
Overview ¶
Package basemodule BaseModule定义
Package basemodule 模块管理器 ¶
Package basemodule 服务节点实例定义
Index ¶
- func NewModuleServerSession(name string, node *registry.Node) (app.IModuleServerSession, error)
- type ModuleBase
- func (this *ModuleBase) Call(ctx context.Context, moduleServer, _func string, params mqrpc.ParamOption, ...) (any, error)
- func (this *ModuleBase) CallBroadcast(ctx context.Context, moduleType, _func string, params ...any)
- func (this *ModuleBase) CallNR(ctx context.Context, moduleServer, _func string, params ...any) (err error)
- func (this *ModuleBase) GetImpl() app.IRPCModule
- func (this *ModuleBase) GetModuleSettings() *conf.ModuleSettings
- func (this *ModuleBase) GetRouteServer(service string, opts ...selector.SelectOption) (s app.IModuleServerSession, err error)
- func (this *ModuleBase) GetServer() server.Server
- func (this *ModuleBase) GetServerByID(serverID string) (app.IModuleServerSession, error)
- func (this *ModuleBase) GetServerBySelector(serviceName string, opts ...selector.SelectOption) (app.IModuleServerSession, error)
- func (this *ModuleBase) GetServerID() string
- func (this *ModuleBase) GetServersByType(serviceName string) []app.IModuleServerSession
- func (this *ModuleBase) Init(impl app.IRPCModule, settings *conf.ModuleSettings, opt ...server.Option)
- func (this *ModuleBase) OnAppConfigurationLoaded()
- func (this *ModuleBase) OnBeforeHandle(fn string, callInfo *mqrpc.CallInfo) error
- func (this *ModuleBase) OnComplete(fn string, callInfo *mqrpc.CallInfo, result *core.ResultInfo, execTime int64)
- func (this *ModuleBase) OnConfChanged(settings *conf.ModuleSettings)
- func (this *ModuleBase) OnDestroy()
- func (this *ModuleBase) OnError(fn string, callInfo *mqrpc.CallInfo, err error)
- func (this *ModuleBase) OnInit(settings *conf.ModuleSettings)
- func (this *ModuleBase) OnMethodNotFound(fn string) (*mqrpc.MethodInfo, error)
- func (this *ModuleBase) OnTimeOut(fn string, Expired int64)
- func (this *ModuleBase) Register(msg string, f interface{})
- func (this *ModuleBase) RegisterGO(msg string, f interface{})
- func (this *ModuleBase) Run(closeSig chan bool)
- func (this *ModuleBase) SetListener(listener mqrpc.IRPCListener)
- type ModuleManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewModuleServerSession ¶ added in v1.2.0
NewModuleServerSession 创建一个节点实例的访问Session(rpcClient)
Types ¶
type ModuleBase ¶
ModuleBase 默认的RPCModule实现
func (*ModuleBase) Call ¶
func (this *ModuleBase) Call(ctx context.Context, moduleServer, _func string, params mqrpc.ParamOption, opts ...selector.SelectOption) (any, error)
Call RPC调用(需要等待结果)
func (*ModuleBase) CallBroadcast ¶
func (this *ModuleBase) CallBroadcast(ctx context.Context, moduleType, _func string, params ...any)
CallBroadcast RPC调用(群发,无需等待结果)
func (*ModuleBase) CallNR ¶
func (this *ModuleBase) CallNR(ctx context.Context, moduleServer, _func string, params ...any) (err error)
CallNR RPC调用(需要等待结果)
func (*ModuleBase) GetModuleSettings ¶
func (this *ModuleBase) GetModuleSettings() *conf.ModuleSettings
GetModuleSettings 获取Config.Module[typ].Settings
func (*ModuleBase) GetRouteServer ¶
func (this *ModuleBase) GetRouteServer(service string, opts ...selector.SelectOption) (s app.IModuleServerSession, err error)
GetRouteServer 获取服务实例(通过服务ID|服务类型,可设置选择器过滤)
func (*ModuleBase) GetServer ¶
func (this *ModuleBase) GetServer() server.Server
GetServer server.Server
func (*ModuleBase) GetServerByID ¶
func (this *ModuleBase) GetServerByID(serverID string) (app.IModuleServerSession, error)
GetServerByID 通过服务ID(moduleType@id)获取服务实例
func (*ModuleBase) GetServerBySelector ¶
func (this *ModuleBase) GetServerBySelector(serviceName string, opts ...selector.SelectOption) (app.IModuleServerSession, error)
GetServerBySelector 通过服务类型(moduleType)获取服务实例(可设置选择器)
func (*ModuleBase) GetServersByType ¶
func (this *ModuleBase) GetServersByType(serviceName string) []app.IModuleServerSession
GetServersByType 通过服务类型(moduleType)获取服务实例列表
func (*ModuleBase) Init ¶
func (this *ModuleBase) Init(impl app.IRPCModule, settings *conf.ModuleSettings, opt ...server.Option)
Init 模块初始化(由派生类调用)
func (*ModuleBase) OnAppConfigurationLoaded ¶
func (this *ModuleBase) OnAppConfigurationLoaded()
OnAppConfigurationLoaded 当应用配置加载完成时调用
func (*ModuleBase) OnBeforeHandle ¶ added in v1.2.0
func (this *ModuleBase) OnBeforeHandle(fn string, callInfo *mqrpc.CallInfo) error
OnBeforeHandle hander执行前调用
func (*ModuleBase) OnComplete ¶
func (this *ModuleBase) OnComplete(fn string, callInfo *mqrpc.CallInfo, result *core.ResultInfo, execTime int64)
OnComplete hander成功执行完成时调用
func (*ModuleBase) OnConfChanged ¶
func (this *ModuleBase) OnConfChanged(settings *conf.ModuleSettings)
OnConfChanged 当配置变更时调用(目前没用)
func (*ModuleBase) OnError ¶
func (this *ModuleBase) OnError(fn string, callInfo *mqrpc.CallInfo, err error)
OnError hander执行错误调用
func (*ModuleBase) OnInit ¶
func (this *ModuleBase) OnInit(settings *conf.ModuleSettings)
OnInit 当模块初始化时调用
func (*ModuleBase) OnMethodNotFound ¶ added in v1.2.0
func (this *ModuleBase) OnMethodNotFound(fn string) (*mqrpc.MethodInfo, error)
OnMethodNotFound 当hander未找到时调用
func (*ModuleBase) OnTimeOut ¶
func (this *ModuleBase) OnTimeOut(fn string, Expired int64)
OnTimeOut hander执行超时调用
func (*ModuleBase) Register ¶ added in v1.2.0
func (this *ModuleBase) Register(msg string, f interface{})
Register 注册rpc消息
func (*ModuleBase) RegisterGO ¶ added in v1.2.0
func (this *ModuleBase) RegisterGO(msg string, f interface{})
RegisterGO 注册rpc消息(go)
func (*ModuleBase) Run ¶ added in v1.2.0
func (this *ModuleBase) Run(closeSig chan bool)
Run 由派生类实现(不可调用基类Run)
func (*ModuleBase) SetListener ¶
func (this *ModuleBase) SetListener(listener mqrpc.IRPCListener)
SetListener mqrpc.RPCListener
type ModuleManager ¶
type ModuleManager struct {
// contains filtered or unexported fields
}
ModuleManager 模块管理器
func (*ModuleManager) RegisterRun ¶ added in v1.2.0
func (this *ModuleManager) RegisterRun(mi app.IModule)
RegisterRun 注册需要运行的模块