Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Register ¶
func Register(closer GracefulClose)
Types ¶
type Func ¶
type Func func()
如果无法让被关闭的对象实现接口,可以通过类型转换一个func()形式的闭包函数,来简单地实现GracefulClose接口 if the shutdown logic is just a function but not a struct, that's ok. just cast it type to Func. for example:
func YourCloseProcedure(){ your code }
Call it like this: Register(shutdown.Func(YourCloseProcedure))
func (Func) OnShutdown ¶
func (shutdown Func) OnShutdown()
type GracefulClose ¶
type GracefulClose interface {
OnShutdown()
}
被关闭者要实现的接口 the only interface that need to be implemented
type ShutdownQueue ¶
type ShutdownQueue struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.