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
//! Demonstrates the minimal supervisor quickstart flow.
// Import the YAML configuration loader.
use rust_supervisor::config::loader::load_config_from_yaml_file;
// Import the supervisor runtime entry point.
use rust_supervisor::runtime::supervisor::Supervisor;
// Define the shared example result type.
type ExampleResult = Result<(), rust_supervisor::error::types::SupervisorError>;
// Use the Tokio runtime for the asynchronous example.
#[tokio::main]
// Return typed supervisor errors from the example.
/// Runs the supervisor quickstart example.
async fn main() -> ExampleResult {
// Load centralized YAML configuration.
let state = load_config_from_yaml_file("examples/config/supervisor.yaml")?;
// Derive the supervisor specification from configuration.
let spec = state.to_supervisor_spec()?;
// Start the supervisor runtime from the specification.
let supervisor_handle = Supervisor::start(spec).await?;
// Query the current runtime state.
let current = supervisor_handle.current_state().await?;
// Print the current state for the learner.
println!("{current:#?}");
// Use the runtime handle for the shutdown request.
supervisor_handle
// Request tree shutdown with audit metadata.
.shutdown_tree("operator", "quickstart complete")
// Wait for the shutdown command result.
.await?;
let current = supervisor_handle.current_state().await?;
println!("{current:#?}");
// Finish the example successfully.
Ok(())
// End the quickstart example.
}