module

package
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2025 License: Apache-2.0 Imports: 16 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 NewModuleSession

func NewModuleSession(name string, node *registry.Node) (app.IServerSession, error)

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

func (this *ModuleBase) GetServerID() string

GetServerID 模块服务ID

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

func NewModuleManager() *ModuleManager

NewModuleManager 新建模块管理器

func (*ModuleManager) CheckModuleSettings

func (this *ModuleManager) CheckModuleSettings()

CheckModuleSettings module配置文件规则检查(ID全局必须唯一) 且 每个类型的Module在同一个ProcessEnv中只能配置一个

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

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

RegisterRunMod 注册需要运行的模块

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