Expand description
Supervision for forge’s long-lived background tasks.
One registry owns every member: it starts the member’s future, observes
its completion through a [JoinSet], restarts a death with bounded
backoff, refuses to resurrect a deliberate stop, and answers a snapshot
of what is running. A member’s own loop is untouched; only its spawn and
its idempotency live here.
Re-exports§
pub(crate) use std::collections::HashMap;🔒pub(crate) use std::future::Future;🔒pub(crate) use std::pin::Pin;🔒pub(crate) use Arc;🔒pub(crate) use Mutex;🔒pub(crate) use PoisonError;🔒pub(crate) use Weak;🔒pub(crate) use Duration;🔒pub(crate) use SystemTime;🔒pub(crate) use tokio::sync::mpsc;🔒pub(crate) use AbortHandle;🔒pub(crate) use Id;🔒pub(crate) use JoinError;🔒pub(crate) use JoinSet;🔒pub(crate) use tokio_util::sync::CancellationToken;🔒
Structs§
- Inner 🔒
- Member
- One member as a snapshot reports it.
- Run 🔒
- State 🔒
- Supervisor
- The process’s supervisor. Cheap to clone; every clone reaches the same registry.
Enums§
- Command 🔒
- Member
State - What a member is doing, as a snapshot reports it.
- Policy
- How a member’s death is handled.
Constants§
- DEFAULT_
CAP - The longest wait between restarts.
- DEFAULT_
GIVE_ UP_ AFTER - How many consecutive failures a member is restarted through.
- DEFAULT_
RESET_ AFTER - How long a run must last before its death starts the count over.
- DEFAULT_
START - The first wait after a death.
Functions§
- abort_
run 🔒 - Abort the run of
nameatgeneration, if that run is still the one registered. A newer run’s handle is keyed by its own generation, so a stop that raced a fresh spawn leaves the new run alone. - backoff 🔒
- The wait before restart number
restarts:startdoubling, capped. - drive 🔒
- The registry’s one task: it owns the [
JoinSet], so a completion is observed with no per-member handle. - error_
reason 🔒 - Why a run ended, in the words the snapshot and the log carry.
- on_exit 🔒
- One run ended. A stop is recorded and left alone; a death is recorded and restarted per policy.
- start_
run 🔒 - Spawn one run of
name, unless a newer run has replaced it.restartcarries the death’s reason when this is a restart.
Type Aliases§
- Factory 🔒
- A member’s future factory: called once per run, so a restart builds a fresh future from the same captured state. Shared rather than boxed so a caller can clone it out from under the registry lock before invoking it.