Documentation ¶
Overview ¶
Package app implements functionality useful for bootstraping an application.
Manager handles the lifecycle of registered components and graceful shutdowns in case of errors or system signals.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is the core app component tasked with coordination of the registered runners and their lifecycle, as well as responding to system signals.
For example, in case of a SIGINT or SIGTERM the underlying context will be canceled and runner.Close() methods will be invoked.
func (*Manager) Add ¶
Add a runner to the manager.
Returns the manager instance for method chaining.
type Runner ¶
type Runner interface { // Run the component. // Runner might perform a blocking call. // // Upon receiving a context.Done() no further "units work" should be // accepted by the runner. // // If the runner wants to signal an issue to the manager, then an error // should be returned. Run(context.Context) error // Close is used to shutdown the runner in a graceful manner. Close() error }
Runner is an app component, who's lifecycle will be managed by the Manager.
func NewRunner ¶
NewRunner creates a new runner from a run and close function.
Useful when a struct doesn't implement the Runner interface.
func NopCloseRunner ¶
NopCloseRunner creates a runner with a noop closer.