Documentation
¶
Overview ¶
Package util adds additional utilities.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ShutdownHandler ¶
type ShutdownHandler func() error
ShutdownHandler is any function that has no parameters and can return an error.
Shutdown handlers are the last resort for the application when there is no more flow control in the user's hand.
Returned errors are logged.
func ShutdownFunc ¶
func ShutdownFunc(fn func()) ShutdownHandler
ShutdownFunc wraps a function withot an error return type.
To make sure there are no silenced errors, panics are also recovered.
type ShutdownManager ¶
type ShutdownManager struct {
// contains filtered or unexported fields
}
ShutdownManager manages an application shutdown by calling the registered handlers.
func NewShutdownManager ¶
func NewShutdownManager(errorHandler errors.Handler) *ShutdownManager
NewShutdownManager creates a new Shutdown manager.
func (*ShutdownManager) Register ¶
func (sm *ShutdownManager) Register(handlers ...ShutdownHandler)
Register appends new shutdown handlers to the list of existing ones.
func (*ShutdownManager) RegisterAsFirst ¶
func (sm *ShutdownManager) RegisterAsFirst(handlers ...ShutdownHandler)
RegisterAsFirst prepends new shutdown handlers to the list of existing ones.
func (*ShutdownManager) Shutdown ¶
func (sm *ShutdownManager) Shutdown()
Shutdown is the panic recovery and shutdown handler.
It should be called as the last method in `main` (eg. using defer).