rust-tokio-supervisor 0.1.4

A Rust tokio supervisor with declarative task supervision, restart policy, shutdown coordination, and observability.
Documentation
//! 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]
/// Runs the minimal supervisor quickstart flow.
///
/// # Returns
///
/// Returns `Ok(())` after the configured supervisor starts, reports state,
/// and shuts down successfully.
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?;

    // Query the state after shutdown.
    let current = supervisor_handle.current_state().await?;
    println!("{current:#?}");

    // Finish the example successfully.
    Ok(())
}