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
use crateRuntimeError;
use Arc;
use AtomicBool;
use Duration;
/// Minimum allowed interval for resource health checks.
pub const MIN_HEALTH_INTERVAL: Duration = from_secs;
/// Shared health state for all registered resources.
/// Fixed-size array allocated once from the resource registry. Each entry is
/// (resource name, healthy flag). Health check tasks write the AtomicBool;
/// the `/health` endpoint reads it. Zero allocation at request time.
pub type HealthState = ;
/// A managed external resource that participates in the runtime lifecycle.
///
/// Implement this trait on database pools, caches, message brokers, or any
/// long-lived resource that needs health checking and graceful shutdown.
///
/// All methods are synchronous, and the two lifecycle hooks differ in what
/// context they run under:
///
/// - `health_check` runs inside the Tokio runtime — on a blocking worker for
/// the startup probe, through `block_in_place` for every later one — and
/// under the Camber runtime context, so it may bridge async work with
/// [`runtime::block_on`].
/// - `shutdown` runs on a plain OS thread after the root scope has drained,
/// with no Tokio runtime entered. Bridging async work there has no runtime
/// to bridge onto.
///
/// [`runtime::block_on`]: crate::runtime::block_on