Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetStartTimeout ¶
SetStartTimeout 设置启动超时时间
Types ¶
type LifeAdmin ¶
type LifeAdmin struct {
// contains filtered or unexported fields
}
LifeAdmin 生命周期管理
func NewLifeAdmin ¶
NewLifeAdmin 实例化方法
Example ¶
// 默认配置 // admin = NewLifeAdmin() // 可供选择配置选项 // 设置启动超时时间 // <=0 不启动超时时间,注意要在shutdown处理关闭通知 // SetStartTimeout(time.Second) // 设置关闭超时时间 // <=0 不启动超时时间 // SetStopTimeout(time.Second) // 设置信号集合,和处理信号的函数 //SetSignal(func(lifeAdmin *LifeAdmin, signal os.Signal) { // return //}, signal...) admin = NewLifeAdmin(SetStartTimeout(time.Second), SetStopTimeout(time.Second), SetSignal(func(a *LifeAdmin, signal os.Signal) { switch signal { case syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGINT: a.shutdown() default: } }))
Output:
func (*LifeAdmin) Add ¶
Add 添加成员表(通过内部 Member 对象添加)
Example ¶
// 通过struct添加 admin.Add(Member{ Start: mockStart(), Shutdown: mockShutdown(), })
Output:
func (*LifeAdmin) AddMember ¶
func (l *LifeAdmin) AddMember(la LifeAdminer)
AddMember 添加程序表(通过外部接口 LifeAdminer 添加)
Example ¶
// 根据接口适配添加 admin.AddMember(&mockLifeAdminer{})
Output:
type LifeAdminer ¶
LifeAdminer 生命周期管理接口
Click to show internal directories.
Click to hide internal directories.