Documentation
¶
Index ¶
- type Enabler
- type HealthChecker
- type IService
- type Option
- func WithAfterStart(fn func() error) Option
- func WithAfterStartFinished(fn func() error) Option
- func WithAfterStop(fn func() error) Option
- func WithBeforeStart(fn func() error) Option
- func WithBeforeStop(fn func() error) Option
- func WithContext(ctx context.Context) Option
- func WithEnabled(v bool) Option
- func WithLogger(l logger.Logger) Option
- func WithName(n string) Option
- func WithService(svc any) Option
- func WithShutdownTimeout(v time.Duration) Option
- func WithSignal(b bool) Option
- func WithStart(fn func(context.Context) error) Option
- func WithStop(fn func(context.Context) error) Option
- type Options
- type Service
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HealthChecker ¶ added in v0.1.0
type HealthChecker interface {
Name() string
Interval() time.Duration
Healthy(ctx context.Context) error
}
HealthChecker provides functionality to check health of any entity that implement this interface.
type Option ¶
type Option func(o *Options)
func WithAfterStart ¶
WithAfterStart run funcs after service starts.
func WithAfterStartFinished ¶
WithAfterStartFinished run funcs after was finished service start func.
func WithAfterStop ¶
WithAfterStop run funcs after service stops.
func WithBeforeStart ¶
WithBeforeStart run funcs before service starts.
func WithBeforeStop ¶
WithBeforeStop run funcs before service stops.
func WithContext ¶
func WithEnabled ¶
func WithLogger ¶
func WithService ¶
func WithShutdownTimeout ¶
func WithSignal ¶
HandleSignal toggles automatic installation of the signal handler that traps TERM, INT, and QUIT. Users of this feature to disable the signal handler, should control liveness of the service through the context.
type Options ¶
type Options struct {
Logger logger.Logger
Name string
Enabled bool
HealthChecker HealthChecker
StartFn func(ctx context.Context) error
StopFn func(ctx context.Context) error
// Before and After funcs
BeforeStart []func() error
BeforeStop []func() error
AfterStart []func() error
AfterStartFinished []func() error
AfterStop []func() error
Signal bool
Context context.Context //nolint:containedctx
// Default 10 seconds
ShutdownTimeout time.Duration
}
Options for service.
Click to show internal directories.
Click to hide internal directories.