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
//! YAML helpers for configuration examples and tests.
//!
//! The module exposes an explicit YAML parsing boundary for callers that already
//! hold configuration text in memory.
use crateSupervisorConfig;
use crateConfigState;
use crateSupervisorError;
/// Parses a YAML string into validated configuration state.
///
/// # Arguments
///
/// - `yaml`: YAML document containing the full supervisor configuration.
///
/// # Returns
///
/// Returns validated [`ConfigState`] when all runtime tunables are present.
///
/// # Examples
///
/// ```
/// let yaml = r#"
/// supervisor:
/// strategy: RestForOne
/// policy:
/// child_restart_limit: 10
/// child_restart_window_ms: 60000
/// supervisor_failure_limit: 30
/// supervisor_failure_window_ms: 60000
/// initial_backoff_ms: 10
/// max_backoff_ms: 1000
/// jitter_ratio: 0.0
/// heartbeat_interval_ms: 1000
/// stale_after_ms: 3000
/// shutdown:
/// graceful_timeout_ms: 1000
/// abort_wait_ms: 100
/// observability:
/// event_journal_capacity: 64
/// metrics_enabled: true
/// audit_enabled: true
/// "#;
/// let state = rust_supervisor::config::yaml::parse_config_state(yaml).unwrap();
/// assert_eq!(state.supervisor.strategy, rust_supervisor::spec::supervisor::SupervisionStrategy::RestForOne);
/// assert_eq!(state.policy.child_restart_limit, 10);
/// ```