Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
type Callback interface { // OnShutdown will be called when shutdown is triggered. The parameter // is the name of the shutdown trigger that trigger shutdown. OnShutdown(string) error }
Callback is an interface you have to implement for callbacks.
type CallbackFunc ¶
CallbackFunc is a helper type, so you can easily provide anonymous functions as shutdown Callbacks.
func (CallbackFunc) OnShutdown ¶
func (f CallbackFunc) OnShutdown(trigger string) error
type ErrorFunc ¶
type ErrorFunc func(err error)
ErrorFunc is a helper type, so you can easily provide anonymous functions as ErrorHandlers.
type ErrorHandler ¶
type ErrorHandler interface {
OnError(error)
}
ErrorHandler is an interface you can pass to SetErrorHandler to handle asynchronous errors.
type ExecuteFunc ¶
type ExecuteFunc func(Trigger)
ExecuteFunc defines the execute func.
func (ExecuteFunc) Execute ¶
func (f ExecuteFunc) Execute(trigger Trigger)
type Executor ¶
type Executor interface {
Execute(Trigger)
}
Executor is the interface of execute func after triggering shutdown.
type Shutdown ¶
type Shutdown interface { // Start starts the graceful shutdown controller. Start() error // AddCallback adds callback func to the shutdown controller. AddCallback(Callback) // SetErrorHandler set errorHandler for the shutdown controller. SetErrorHandler(ErrorHandler) }
Shutdown is an interface implemented by shutdownController, that receives shutdown triggers when shutdown is requested.
type Trigger ¶
type Trigger interface { // GetName returns the name of the trigger. GetName() string // Start starts the trigger to listen some shutdown requests. Start(Executor) error // After fun do something after shutdown, like exit. After() }
Trigger is an interface implemnted by shutdown triggers.