supervisor_quickstart/supervisor_quickstart.rs
1//! Demonstrates the minimal supervisor quickstart flow.
2
3// Import the YAML configuration loader.
4use rust_supervisor::config::loader::load_config_state;
5// Import the supervisor runtime entry point.
6use rust_supervisor::runtime::supervisor::Supervisor;
7
8// Define the shared example result type.
9type ExampleResult = Result<(), rust_supervisor::error::types::SupervisorError>;
10
11// Use the Tokio runtime for the asynchronous example.
12#[tokio::main]
13// Return typed supervisor errors from the example.
14/// Runs the supervisor quickstart example.
15async fn main() -> ExampleResult {
16 // Load centralized YAML configuration.
17 let state = load_config_state("examples/config/supervisor.yaml")?;
18 // Derive the supervisor specification from configuration.
19 let spec = state.to_supervisor_spec()?;
20 // Start the supervisor runtime from the specification.
21 let handle = Supervisor::start(spec).await?;
22 // Query the current runtime state.
23 let current = handle.current_state().await?;
24 // Print the current state for the learner.
25 println!("{current:#?}");
26 // Use the runtime handle for the shutdown request.
27 handle
28 // Request tree shutdown with audit metadata.
29 .shutdown_tree("operator", "quickstart complete")
30 // Wait for the shutdown command result.
31 .await?;
32 // Finish the example successfully.
33 Ok(())
34 // End the quickstart example.
35}