core

package
v0.0.0-...-595b576 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	AppStateNone = iota // 未开始或已停止
	AppStateInit        // 正在初始化中
	AppStateRun         // 正在运行中
	AppStateStop        // 正在停止中
)

节点全局状态

Variables

This section is empty.

Functions

func AddDynamicModules

func AddDynamicModules(mods ...IModule) error

AddDynamicModules 默认单实例, 添加动态模块

func DynamicModules

func DynamicModules() []string

DynamicModules 默认单实例, 动态模块

func GetChanRPC

func GetChanRPC(name string) *chanrpc.Server

GetChanRPC 默认单实例, 消息通道

func GetState

func GetState() int32

GetState 默认单实例, 获取应用程序状态

func Register

func Register(mods ...IModule) error

Register 默认单实例, 注册模块

func RemoveDynamicModule

func RemoveDynamicModule(name string) bool

RemoveDynamicModule 默认单实例, 删除动一个动态模块

func Run

func Run(mods ...IModule)

Run 默认单实例, 运行应用程序

func Stats

func Stats() string

Stats 默认单实例, 所有模块状态

Types

type IModule

type IModule interface {
	Name() string                // 名称
	Priority() uint              // 模块优先级, 值越小优先级越高
	OnInit() error               // 初始化
	OnStart(ctx context.Context) // 启动, 阻塞
	OnDestroy()                  // 销毁
	ChanRPC() *chanrpc.Server    // 消息通道
}

IModule 模块接口

type IRPC

type IRPC interface {
	Cast(mod string, req any)
	Call(mod string, req any) *chanrpc.RetInfo
	AsyncCall(mod string, req any, cb chanrpc.Callback) error
}

type ITimer

type ITimer interface {
	RegisterTimer(kind string, handler timermgr.TimerHandler)
	NewTimer(duraMs int64, kind string, metadata map[string]string) int64
	NewTicker(duraMs int64, kind string, metadata map[string]string) int64
	AccTimer(id int64, kind timermgr.AccKind, value int64) error
	DelayTimer(id int64, kind timermgr.AccKind, value int64) (err error)
	CancelTimer(id int64)
}

type Skeleton

type Skeleton struct {
	// contains filtered or unexported fields
}

Skeleton 基础框架

func NewSkeleton

func NewSkeleton(name string) *Skeleton

NewSkeleton 创建Skeleton, l为定时器数量

func (*Skeleton) AccTimer

func (s *Skeleton) AccTimer(id int64, kind timermgr.AccKind, value int64) error

func (*Skeleton) AsyncCall

func (s *Skeleton) AsyncCall(mod string, req any, cb chanrpc.Callback) error

func (*Skeleton) Call

func (s *Skeleton) Call(mod string, req any) *chanrpc.RetInfo

func (*Skeleton) CancelTimer

func (s *Skeleton) CancelTimer(id int64)

func (*Skeleton) Cast

func (s *Skeleton) Cast(mod string, req any)

func (*Skeleton) ChanRPC

func (s *Skeleton) ChanRPC() *chanrpc.Server

ChanRPC 获取ChanRPC

func (*Skeleton) DelayTimer

func (s *Skeleton) DelayTimer(id int64, kind timermgr.AccKind, value int64) (err error)

func (*Skeleton) Name

func (s *Skeleton) Name() string

Name 名称

func (*Skeleton) NewTicker

func (s *Skeleton) NewTicker(id int64, duraMs int64, kind string, metadata map[string]string) int64

NewTicker 启动Ticker,id为0则新建,否则复用id

func (*Skeleton) NewTimer

func (s *Skeleton) NewTimer(duraMs int64, kind string, metadata map[string]string) int64

NewTimer 启动Timer

func (*Skeleton) OnStart

func (s *Skeleton) OnStart(ctx context.Context)

OnStart 启动

func (*Skeleton) RegisterChanRPC

func (s *Skeleton) RegisterChanRPC(msg any, f chanrpc.Handler) error

func (*Skeleton) RegisterTimer

func (s *Skeleton) RegisterTimer(kind string, handler timermgr.TimerHandler)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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