Documentation ¶
Index ¶
- type Error
- type Handler
- type HandlerBuilder
- func (b *HandlerBuilder) AddSignal(value os.Signal) *HandlerBuilder
- func (b *HandlerBuilder) AddSignals(values ...os.Signal) *HandlerBuilder
- func (b *HandlerBuilder) Build() (result *Handler, err error)
- func (b *HandlerBuilder) SetLogger(logger *slog.Logger) *HandlerBuilder
- func (b *HandlerBuilder) SetSignal(value os.Signal) *HandlerBuilder
- func (b *HandlerBuilder) SetSignals(values ...os.Signal) *HandlerBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error int
Error is an error type that contains a process exit code. This is itended for situations where you want to call os.Exit only in one place, but also want some deeply nested functions to decide what should be the exit code.
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler knows how to wait for exit signals and how to execute exit actions before exiting.
type HandlerBuilder ¶
type HandlerBuilder struct {
// contains filtered or unexported fields
}
HandlerBuilder contains the data and logic needed to build an exit handler.
func NewHandler ¶
func NewHandler() *HandlerBuilder
NewHandler creates a builder that can then be used to configure and create an exit handler.
func (*HandlerBuilder) AddSignal ¶
func (b *HandlerBuilder) AddSignal(value os.Signal) *HandlerBuilder
AddSignal adds a shutdown signal. Signals SIGINT and SIGTERM are included by default.
func (*HandlerBuilder) AddSignals ¶
func (b *HandlerBuilder) AddSignals(values ...os.Signal) *HandlerBuilder
AddSignals adds a list of exit signal. Signals SIGINT and SIGTERM are included by default.
func (*HandlerBuilder) Build ¶
func (b *HandlerBuilder) Build() (result *Handler, err error)
Build uses the data stored in the builder to create and configure a new exit handler.
func (*HandlerBuilder) SetLogger ¶
func (b *HandlerBuilder) SetLogger(logger *slog.Logger) *HandlerBuilder
SetLogger sets the logger that the handler will use to write to the log. This is mandatory.
func (*HandlerBuilder) SetSignal ¶
func (b *HandlerBuilder) SetSignal(value os.Signal) *HandlerBuilder
SetSignal sets the exit signal, discarding any signals that have been previosly configured, including the defaults.
func (*HandlerBuilder) SetSignals ¶
func (b *HandlerBuilder) SetSignals(values ...os.Signal) *HandlerBuilder
SetSignals sets a list of exit signal, discarding any signals that have been previosly configured, including the defaults.