Documentation ¶
Index ¶
- type Callback
- type CallbackFunc
- type ErrorHandler
- type GSInterface
- type GracefulShutdown
- func (gs *GracefulShutdown) AddCallback(callback Callback)
- func (gs *GracefulShutdown) AddManager(manager Manager)
- func (gs *GracefulShutdown) ReportError(err error)
- func (gs *GracefulShutdown) SetErrorHandler(errorHandler ErrorHandler)
- func (gs *GracefulShutdown) Start() error
- func (gs *GracefulShutdown) StartShutdown(manager Manager)
- type Manager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackFunc ¶
CallbackFunc 是一个辅助函数,用于自定义回调函数.
func (CallbackFunc) OnShutdown ¶
func (f CallbackFunc) OnShutdown(manager string) error
OnShutdown 是在 shutdown 触发时执行的方法.
type ErrorHandler ¶
type ErrorHandler interface {
OnError(err error)
}
type GSInterface ¶
type GSInterface interface { AddManager(manager Manager) // 添加 Shutdown Manager AddCallback(callback Callback) // 添加 Shutdown Callback SetErrorHandler(errorHandler ErrorHandler) // 设置 ErrorHandler StartShutdown(manager Manager) // 执行指定 Manager 的 shutdown ReportError(err error) // 向 ErrorHandler 报错 }
type GracefulShutdown ¶
type GracefulShutdown struct {
// contains filtered or unexported fields
}
func (*GracefulShutdown) AddCallback ¶
func (gs *GracefulShutdown) AddCallback(callback Callback)
AddCallback 添加 Callback 以便在 shutdown 时调用.
func (*GracefulShutdown) AddManager ¶
func (gs *GracefulShutdown) AddManager(manager Manager)
AddManager 添加 Manager 用于监听 shutdown 请求.
func (*GracefulShutdown) ReportError ¶
func (gs *GracefulShutdown) ReportError(err error)
ReportError 用于向 ErrorHandler 报错.
func (*GracefulShutdown) SetErrorHandler ¶
func (gs *GracefulShutdown) SetErrorHandler(errorHandler ErrorHandler)
SetErrorHandler 设置 ErrorHandler 用于在 Manager 或 Callback 失败时调用.
func (*GracefulShutdown) Start ¶
func (gs *GracefulShutdown) Start() error
Start 在所有已添加的 Manager 上启动监听.
func (*GracefulShutdown) StartShutdown ¶
func (gs *GracefulShutdown) StartShutdown(manager Manager)
StartShutdown 用于执行指定 Manager 的 shutdown.
Click to show internal directories.
Click to hide internal directories.