Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Module ¶
type Module struct {
ModuleLoaders []ModuleLoader
}
func (*Module) Unload ¶
func (m *Module) Unload(maxWaitSeconds uint) []ShutdownResult
Unload 依次卸载每个模块 仅在上一个模块成功卸载后处理下一个 忽略UnregisterConfig配置 param maxWaitSeconds 等待优雅停机的最大时间(秒) 该时间将分别作用于每个模块 return map[string]ShutdownResult
func (*Module) UnloadByConfig ¶
func (m *Module) UnloadByConfig() []ShutdownResult
UnloadByConfig 根据配置规则卸载模块,如果未配置config,将自动使用默认配置进行卸载 默认配置: 优先级最低(且不保证顺序) 同步卸载 最大优雅停机等待时机20s
type ModuleConfig ¶
type ModuleConfig struct { // 模块名称 ModuleName string // 注册模块的拦截器,用于获取原始模块的实例,进行拓展配置 LoadInterceptor func(instance interface{}) // 卸载时优先级,权重越小,优先级越高 // 注意,相同的优先级会导致不稳定排序出现不稳定的同优先级先后顺序 UnregisterPriority uint // 是否允许该模块异步卸载 // true 执行异步卸载,触发卸载后不立即等待卸载结果 UnregisterAllowAsync bool // 等待优雅停机的最大时间 (秒) UnregisterMaxWaitSeconds uint }
ModuleConfig 卸载模块时对应的配置 注意 直接执行Unload函数,卸载配置将忽略,执行按照加载顺序卸载
type ModuleLoader ¶
type ModuleLoader interface { // ModuleConfig 设置卸载模块时配置 ModuleConfig() *ModuleConfig // Register 声明模块的注册启动方法 Register() (interface{}, error) // Unregister 声明模块的卸载关闭方法 函数会阻塞直到停机完成 // param maxWaitSeconds 等待优雅停机的最大时间 (秒) // return gracefully 是否以优雅停机的形式关闭 Unregister(maxWaitSeconds uint) (gracefully bool, err error) }
ModuleLoader 声明starter加载的通用接口
type ShutdownResult ¶
ShutdownResult 模块停止卸载结果
Click to show internal directories.
Click to hide internal directories.