Documentation ¶
Overview ¶
Package bootstrap provides a simple way to bootstrap an application with a managed logging framework, metrics and application context.
Index ¶
- func Bootstrap(bindFn BindFunc, opts ...Option) error
- type BindFunc
- type CreateLoggerFunc
- type CreateMetricsClientFunc
- type Option
- func WithContext(ctx context.Context) Option
- func WithCreateLoggerFunc(fn CreateLoggerFunc) Option
- func WithCreateMetricsClientFunc(fn CreateMetricsClientFunc) Option
- func WithLogger(l *zap.Logger) Option
- func WithShutdownSignalChan(ch chan struct{}) Option
- func WithShutdownTimeout(timeout time.Duration) Option
- func WithShutdownWaitGroup(wg *sync.WaitGroup) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BindFunc ¶
BindFunc represents the function responsible to wire up all components of the application.
type CreateLoggerFunc ¶
CreateLoggerFunc creates a new logger.
type CreateMetricsClientFunc ¶
CreateMetricsClientFunc creates a new metrics client.
type Option ¶
type Option func(*config)
Option is a type alias for a function that configures the application logger.
func WithContext ¶
WithContext overrides the application context (useful for testing).
func WithCreateLoggerFunc ¶
func WithCreateLoggerFunc(fn CreateLoggerFunc) Option
WithCreateLoggerFunc overrides the root logger creation function.
func WithCreateMetricsClientFunc ¶
func WithCreateMetricsClientFunc(fn CreateMetricsClientFunc) Option
WithCreateMetricsClientFunc overrides the default metrics client register.
func WithLogger ¶
WithLogger overrides the default application logger.
func WithShutdownSignalChan ¶ added in v1.73.0
func WithShutdownSignalChan(ch chan struct{}) Option
WithShutdownSignalChan sets the shared channel uset to signal a shutdown. The channel is set when the shutdown process starts. Dependants (e.g. HTTP servers) should read this channel and start their shutdown process.
func WithShutdownTimeout ¶ added in v1.72.0
WithShutdownTimeout sets the shutdown timeout. This is the time to wait on exit for a graceful shutdown.
func WithShutdownWaitGroup ¶ added in v1.72.0
WithShutdownWaitGroup sets the shared waiting group to communicate externally when the server is shutdown. On shutdown Bootstrap will wait for the wg to be zero or the shutdownTimeout to be reached before returning. Dependants (e.g. HTTP servers) should increment this group when they start, and reset it when their shutdown process is completed.