Documentation ¶
Index ¶
- func AppSelfShutdownCaller(handler interface{}, params ...interface{})
- func WithSelfShutdownLogsEnabled(selfShutdownLogsEnabled bool) options.Option[ShutdownHandler]
- func WithSelfShutdownLogsFilePath(selfShutdownLogsFilePath string) options.Option[ShutdownHandler]
- func WithStopGracePeriod(stopGracePeriod time.Duration) options.Option[ShutdownHandler]
- type Events
- type ShutdownHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppSelfShutdownCaller ¶
func AppSelfShutdownCaller(handler interface{}, params ...interface{})
AppSelfShutdownCaller is used to signal a app self shutdown caused by an error.
func WithSelfShutdownLogsEnabled ¶
func WithSelfShutdownLogsEnabled(selfShutdownLogsEnabled bool) options.Option[ShutdownHandler]
WithSelfShutdownLogsEnabled defines whether to store self-shutdown events to a log file.
func WithSelfShutdownLogsFilePath ¶
func WithSelfShutdownLogsFilePath(selfShutdownLogsFilePath string) options.Option[ShutdownHandler]
WithSelfShutdownLogsFilePath defines the file path to the self-shutdown log.
func WithStopGracePeriod ¶
func WithStopGracePeriod(stopGracePeriod time.Duration) options.Option[ShutdownHandler]
WithStopGracePeriod defines the the maximum time to wait for background processes to finish during shutdown before terminating the app.
Types ¶
type Events ¶
type Events struct { // Fired when a app self shutdown was caused by an error. AppSelfShutdown *events.Event // Fired when a clean shutdown was requested. AppShutdown *events.Event }
Events holds Shutdown related events.
type ShutdownHandler ¶
type ShutdownHandler struct { // the logger used to log events. *logger.WrappedLogger // Events are the events that are triggered by the ShutdownHandler. Events *Events // contains filtered or unexported fields }
ShutdownHandler waits until a shutdown signal was received or the app tried to shutdown itself, and shuts down all processes gracefully.
func NewShutdownHandler ¶
func NewShutdownHandler(log *logger.Logger, daemon daemon.Daemon, opts ...options.Option[ShutdownHandler]) *ShutdownHandler
NewShutdownHandler creates a new shutdown handler.
func (*ShutdownHandler) Run ¶
func (gs *ShutdownHandler) Run() error
Run starts the ShutdownHandler go routine.
func (*ShutdownHandler) SelfShutdown ¶
func (gs *ShutdownHandler) SelfShutdown(msg string, critical bool)
SelfShutdown can be called in order to instruct the app to shutdown cleanly without receiving any interrupt signals.