Documentation
¶
Index ¶
- Variables
- type Base
- func (b *Base) AddDependencies(deps ...string)
- func (b *Base) Dependencies() map[string]Module
- func (b *Base) Dependency(name string) Module
- func (b *Base) IsReady() bool
- func (b *Base) Log(lvl zerolog.Level, message string, fields ...any)
- func (b *Base) Logger() *zerolog.Logger
- func (b *Base) ManageReadiness()
- func (b *Base) ManagesReadiness() bool
- func (b *Base) Name() string
- func (b *Base) Ready(_ context.Context) error
- func (b *Base) SetDependency(m Module)
- func (b *Base) SetLogger(l *zerolog.Logger)
- func (b *Base) SetName(name string)
- func (b *Base) SetReady(ready bool)
- type Module
- type Option
- type ReadinessReporter
- type Runtime
- func (r *Runtime) Configure() error
- func (r *Runtime) Module(name string) Module
- func (r *Runtime) NotReady(ctx context.Context) map[string]error
- func (r *Runtime) OrderModules() error
- func (r *Runtime) Ready(ctx context.Context) error
- func (r *Runtime) Register(m Module, opts ...Option)
- func (r *Runtime) Shutdown() error
- func (r *Runtime) Start() error
Constants ¶
This section is empty.
Variables ¶
var ErrNotReady = errors.New("module not ready")
ErrNotReady is returned by Ready for a module that has not finished starting.
Functions ¶
This section is empty.
Types ¶
type Base ¶
type Base struct {
// contains filtered or unexported fields
}
func (*Base) AddDependencies ¶
func (*Base) Dependencies ¶
func (*Base) Dependency ¶
func (*Base) ManageReadiness ¶ added in v0.2.0
func (b *Base) ManageReadiness()
ManageReadiness opts the module out of the runtime marking it ready when Start returns. A module that does so is responsible for calling SetReady itself, and stays unready until it does.
func (*Base) ManagesReadiness ¶ added in v0.2.0
func (*Base) Ready ¶ added in v0.2.0
Ready reports readiness from the readiness flag. Modules that need a richer answer - a probe query, an error captured by a background goroutine - embed Base and override this.
func (*Base) SetDependency ¶
type Module ¶
type Module interface {
Configure(...Option) error
Start() error
Shutdown() error
SetName(string)
Name() string
AddDependencies(...string)
SetDependency(Module)
Dependency(string) Module
Dependencies() map[string]Module
Ready(context.Context) error
IsReady() bool
SetReady(bool)
// ManagesReadiness reports whether the module sets its own readiness. The
// runtime marks every other module ready once its Start returns.
ManageReadiness()
ManagesReadiness() bool
SetLogger(*zerolog.Logger)
Logger() *zerolog.Logger
Log(zerolog.Level, string, ...any)
}
type Option ¶
func WithLogger ¶
type ReadinessReporter ¶ added in v0.2.0
ReadinessReporter reports which modules are not yet ready to serve. The Runtime satisfies it, and modules that need to answer for the whole service - a health endpoint, a readiness probe - receive it through readinessAware rather than holding the Runtime itself.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func NewRuntime ¶
func NewRuntime() *Runtime
func (*Runtime) NotReady ¶ added in v0.2.0
NotReady returns the modules that are not ready to serve, keyed by module name, with the reason each gave.