Skip to main content

Module lifecycle

Module lifecycle 

Source
Expand description

Process lifecycle state machine (PLAN.md Phase 1 — Lifecycle Contract).

Tracks where the runtime is in its boot/serve/shutdown sequence so that:

  • health probes can answer /health/live, /health/ready, /health/startup deterministically (live: process responsive, ready: accepting queries, startup: K8s-style “still warming up”);
  • WriteGate can reject mutations once shutdown is initiated;
  • POST /admin/shutdown is idempotent — subsequent calls return the same successful state without re-running the flush pipeline;
  • orchestrators see a consistent transition pattern regardless of how shutdown was triggered (HTTP, SIGTERM, SIGINT).

The state is a single AtomicU8 in RuntimeInner plus a parking_lot::RwLock<ShutdownReport> for the optional final report. Phase transitions are monotonic — the runtime cannot move backwards through them.

Structs§

ColdStartPhases
PLAN.md Phase 9.1 — cold-start phase snapshot. All fields are wall-clock unix-ms; 0 means the phase hasn’t fired yet.
Lifecycle
Lifecycle state wrapper held in RuntimeInner.
ShutdownReport
Final report produced by a successful graceful shutdown.

Enums§

Phase
Discrete lifecycle phases. Numeric values are monotonic so an AtomicU8 compare_exchange gives us atomic transitions without a mutex. Decoded via Phase::from_u8.