Documentation
¶
Overview ¶
Package lifecycle runs the platform's providers through boot and stop in one order (ADR-0305). A provider implements Provider and any of Starter, Reclaimer, Runner, BeforeStopper and Stopper; Phases runs each hook a provider has: Start, then Reclaim, in list order at boot, Run once every Start passed, BeforeStop and Stop in reverse at stop. It follows the idiom of the invoke chain (ADR-0302): a required interface, and optional ones a type assertion finds. A shared hook is such an optional interface of the package that builds the list, walked with Each and named in the boot log with Named (ADR-0308).
Index ¶
- func Each[H Provider](ph *Phases) []H
- type BeforeStopper
- type Hook
- type Phases
- func (ph *Phases) BeforeStop(ctx context.Context) error
- func (ph *Phases) Hooks(shared ...Hook) []string
- func (ph *Phases) Providers() []Provider
- func (ph *Phases) Reclaim(ctx context.Context) error
- func (ph *Phases) Run(ctx context.Context, wg *sync.WaitGroup)
- func (ph *Phases) Start(ctx context.Context) error
- func (ph *Phases) Stop(ctx context.Context) error
- type Provider
- type Reclaimer
- type Runner
- type Starter
- type Stopper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BeforeStopper ¶
BeforeStopper runs when the daemon is about to close, before any provider stops.
type Hook ¶
type Hook struct {
// contains filtered or unexported fields
}
Hook is an optional provider interface under its boot-log name.
type Phases ¶
type Phases struct {
// contains filtered or unexported fields
}
Phases runs the hooks of its providers in their order. BeforeStop and Stop run for every provider, booted or not, so each must be safe when its Start never ran or failed: a New that fails stops the platform it was building, and a failed Start stops the providers after it too. It is safe for concurrent use; once stopping has begun, Start, Reclaim and Run start no further provider.
func (*Phases) BeforeStop ¶
BeforeStop runs every BeforeStopper in reverse order and joins their errors.
func (*Phases) Hooks ¶
Hooks names each provider with the hooks it has, then each of shared it implements, in list order, for the boot log: "executor: start, run, before stop, stop".
func (*Phases) Reclaim ¶
Reclaim runs each Reclaimer in list order and joins their errors, naming each provider.
func (*Phases) Run ¶
Run starts each Runner on ctx in its own goroutine, counted in wg, unless stopping has begun.
type Provider ¶
type Provider interface {
Name() string
}
Provider is one platform provider; it also implements none or more of Starter, Reclaimer, Runner, BeforeStopper and Stopper.
type Reclaimer ¶
Reclaimer reclaims at boot, after every Start, what its provider's resources deleted before their reconcile ran still hold (ADR-0307). The platform runs it only on a boot that is not held (ADR-0206 Decision 6).
type Runner ¶
Runner runs a provider's long-running work on the platform's run context, from after every Start until that context ends. The platform waits for it with its own loops, before any provider stops.