module

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 4, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package basemodule BaseModule定义

Package basemodule 模块管理器

Package basemodule 服务节点实例定义

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModuleServerSession added in v1.2.0

func NewModuleServerSession(name string, node *registry.Node) (app.IModuleServerSession, error)

NewModuleServerSession 创建一个节点实例的访问Session(rpcClient)

Types

type ModuleBase

type ModuleBase struct {
	//context.Context
	timer.ITimer
	// contains filtered or unexported fields
}

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) GetImpl

func (this *ModuleBase) GetImpl() app.IRPCModule

GetImpl 获取子类

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) GetServerID

func (this *ModuleBase) GetServerID() string

GetServerID 模块服务ID

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) OnDestroy

func (this *ModuleBase) OnDestroy()

OnDestroy 当模块注销时调用

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 NewModuleManager

func NewModuleManager() *ModuleManager

NewModuleManager 新建模块管理器

func (*ModuleManager) Destroy

func (this *ModuleManager) Destroy()

Destroy 停止模块(倒序)

func (*ModuleManager) Init

func (this *ModuleManager) Init(processEnv string)

Init 初始化

func (*ModuleManager) Register

func (this *ModuleManager) Register(mi app.IModule)

Register 注册模块

func (*ModuleManager) RegisterRun added in v1.2.0

func (this *ModuleManager) RegisterRun(mi app.IModule)

RegisterRun 注册需要运行的模块

Directories

Path Synopsis
Package server is an interface for a micro server
Package server is an interface for a micro server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL