1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//! The application lifecycle state machine, readiness gates, and drain
//! hooks (AP2.1-10).
//!
//! This module owns the production process lifecycle: the
//! `STARTING → READY → DRAINING → STOPPED` state machine, the
//! application-registered readiness checks that gate `/up/ready`, and the
//! `DrainHook` seam the Realtime (AP2.1-8) and jobs lanes wire into for
//! coordinated graceful shutdown. One file owns one responsibility
//! (AGENTS.md §1):
//!
//! - [`state`] — the lifecycle state values and their atomic encoding.
//! - [`ready`] — the application-registered readiness gates.
//! - [`hook`] — the `DrainHook` trait and the shutdown-hook registry (the
//! seam the master wires Realtime/jobs into).
//! - [`coordinator`] — the [`Lifecycle`] coordinator handle (state + readiness
//! + hooks; the `live()` / `ready()` queries; the transitions).
//! - [`signal`] — the production termination signal future (Unix SIGTERM/
//! SIGINT, Windows Ctrl-C/Ctrl-Break). `macros`-feature-gated (tokio
//! `signal`).
//!
//! The state machine and readiness gates are pure `std` (atomic + `Arc`) so
//! they compile with no feature flags; an expert user on a custom runtime
//! can build a [`Lifecycle`], mount the framework's [`crate::health`] routes,
//! and drive their own shutdown. The orchestrated paths
//! (`serve_with_health` / `run_with_health`) tie the lifecycle to the
//! certified Tokio runtime and the engine's subsystem startup/shutdown.
// `signal` (the production termination-signal future) needs the certified
// Tokio `signal` sub-feature. It is gated by the same condition as
// `run_with_health` (the only consumer): `macros` + at least one lifecycle
// subsystem feature. Under `macros`-alone the plain `run` path is the
// correct entry point and has no termination-signal consumer.
pub use Lifecycle;
pub use ;
pub use ReadinessCheck;
pub use LifecycleState;
// `termination_signal` needs the certified Tokio `signal` sub-feature, which
// the `macros` feature brings. Exported only when `run_with_health` is
// compiled (same gate).
pub use termination_signal;