Skip to main content

Crate forge_supervise

Crate forge_supervise 

Source
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 🔒
MemberState
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 name at generation, 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: start doubling, 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. restart carries 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.