Module lifecycle

Module lifecycle 

Source
Expand description

Deterministic startup/shutdown helpers (readiness + stop coordination). Deterministic startup/shutdown building blocks.

These helpers are intentionally lightweight and backend-agnostic.

Patterns covered:

  • readiness gating (aggregate multiple components into one “ready” latch)
  • stop flag fanout to threads
  • recording the first fatal error (root cause) and requesting stop

Notes on router ordering:

  • request stop (set the shared stop flag)
  • let stages exit / optionally drain
  • stop routers and join() them (so routing loops terminate deterministically)

Notes on drain windows:

  • when stop is requested, you may choose to keep running a stage loop for a bounded duration (e.g. Instant::now() < deadline) to flush in-flight messages.

Structs§

ReadinessGate
Aggregates multiple components into a single readiness latch.
ReadinessToken
A per-component handle used to mark startup progress.
RootCause
Captures the first fatal error and coordinates process-wide stop.