Documentation
¶
Overview ¶
Package basemodule BaseModule定义
Package basemodule 模块管理器 ¶
Package basemodule 服务节点实例定义
Index ¶
- func NewModuleSession(name string, node *registry.Node) (app.IServerSession, error)
- type ModuleBase
- func (this *ModuleBase) BeforeHandle(fn string, callInfo *mqrpc.CallInfo) error
- func (this *ModuleBase) Call(ctx context.Context, moduleType, _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, moduleType, _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.IServerSession, err error)
- func (this *ModuleBase) GetServer() server.Server
- func (this *ModuleBase) GetServerByID(serverID string) (app.IServerSession, error)
- func (this *ModuleBase) GetServerBySelector(serviceName string, opts ...selector.SelectOption) (app.IServerSession, error)
- func (this *ModuleBase) GetServerID() string
- func (this *ModuleBase) GetServersByType(serviceName string) []app.IServerSession
- func (this *ModuleBase) Init(impl app.IRPCModule, settings *conf.ModuleSettings, opt ...server.Option)
- func (this *ModuleBase) NoFoundFunction(fn string) (*mqrpc.FunctionInfo, error)
- func (this *ModuleBase) OnAppConfigurationLoaded()
- 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) OnTimeOut(fn string, Expired int64)
- func (this *ModuleBase) SetListener(listener mqrpc.RPCListener)
- type ModuleManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewModuleSession ¶
NewModuleSession 创建一个节点实例的访问Session(rpcClient)
Types ¶
type ModuleBase ¶
type ModuleBase struct {
Impl app.IRPCModule
// contains filtered or unexported fields
}
ModuleBase 默认的RPCModule实现
func (*ModuleBase) BeforeHandle ¶
func (this *ModuleBase) BeforeHandle(fn string, callInfo *mqrpc.CallInfo) error
BeforeHandle hander执行前调用
func (*ModuleBase) Call ¶
func (this *ModuleBase) Call(ctx context.Context, moduleType, _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, moduleType, _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.IServerSession, 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.IServerSession, error)
GetServerByID 通过服务ID(moduleType@id)获取服务实例
func (*ModuleBase) GetServerBySelector ¶
func (this *ModuleBase) GetServerBySelector(serviceName string, opts ...selector.SelectOption) (app.IServerSession, error)
GetServerBySelector 通过服务类型(moduleType)获取服务实例(可设置选择器)
func (*ModuleBase) GetServersByType ¶
func (this *ModuleBase) GetServersByType(serviceName string) []app.IServerSession
GetServersByType 通过服务类型(moduleType)获取服务实例列表
func (*ModuleBase) Init ¶
func (this *ModuleBase) Init(impl app.IRPCModule, settings *conf.ModuleSettings, opt ...server.Option)
Init 模块初始化(由派生类调用)
func (*ModuleBase) NoFoundFunction ¶
func (this *ModuleBase) NoFoundFunction(fn string) (*mqrpc.FunctionInfo, error)
NoFoundFunction 当hander未找到时调用
func (*ModuleBase) OnAppConfigurationLoaded ¶
func (this *ModuleBase) OnAppConfigurationLoaded()
OnAppConfigurationLoaded 当应用配置加载完成时调用
func (*ModuleBase) OnComplete ¶
func (this *ModuleBase) OnComplete(fn string, callInfo *mqrpc.CallInfo, result *core.ResultInfo, execTime int64)
OnComplete hander成功执行完成时调用 fn 方法名 params 参数 result 执行结果 exec_time 方法执行时间 单位为 Nano 纳秒 1000000纳秒等于1毫秒
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) OnTimeOut ¶
func (this *ModuleBase) OnTimeOut(fn string, Expired int64)
OnTimeOut hander执行超时调用
func (*ModuleBase) SetListener ¶
func (this *ModuleBase) SetListener(listener mqrpc.RPCListener)
SetListener mqrpc.RPCListener
type ModuleManager ¶
type ModuleManager struct {
// contains filtered or unexported fields
}
ModuleManager 模块管理器
func (*ModuleManager) CheckModuleSettings ¶
func (this *ModuleManager) CheckModuleSettings()
CheckModuleSettings module配置文件规则检查(ID全局必须唯一) 且 每个类型的Module在同一个ProcessEnv中只能配置一个
func (*ModuleManager) RegisterRunMod ¶
func (this *ModuleManager) RegisterRunMod(mi app.IModule)
RegisterRunMod 注册需要运行的模块