Files
ssq-desk/internal/module/module.go
2026-01-14 14:17:38 +08:00

53 lines
985 B
Go

package module
import "context"
// Module 模块接口
type Module interface {
// Name 返回模块名称
Name() string
// Init 初始化模块
Init(ctx context.Context) error
// Start 启动模块
Start(ctx context.Context) error
// Stop 停止模块
Stop(ctx context.Context) error
// GetAPI 获取模块的 API 接口(供前端调用)
GetAPI() interface{}
}
// BaseModule 基础模块实现
type BaseModule struct {
name string
api interface{}
}
// Name 返回模块名称
func (m *BaseModule) Name() string {
return m.name
}
// GetAPI 获取模块的 API 接口
func (m *BaseModule) GetAPI() interface{} {
return m.api
}
// Init 初始化模块(默认实现)
func (m *BaseModule) Init(ctx context.Context) error {
return nil
}
// Start 启动模块(默认实现)
func (m *BaseModule) Start(ctx context.Context) error {
return nil
}
// Stop 停止模块(默认实现)
func (m *BaseModule) Stop(ctx context.Context) error {
return nil
}