Skip to main content

demo/
shutdown.rs

1//! Handles graceful demo shutdown.
2
3// Import supervisor handle used for shutdown commands.
4use rust_supervisor::control::handle::SupervisorHandle;
5
6/// Shuts down the supervisor tree used by the demo.
7///
8/// # Arguments
9///
10/// - `handle`: Runtime handle returned by the supervisor.
11///
12/// # Returns
13///
14/// Returns success after the shutdown command is accepted.
15pub(crate) async fn shutdown_demo(
16    // Continue the demo expression.
17    handle: &SupervisorHandle,
18    // Continue the demo expression.
19) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
20    // Send a visible shutdown reason through the public handle.
21    handle.shutdown_tree("operator", "demo shutdown").await?;
22    // Finish graceful shutdown.
23    Ok(())
24    // End shutdown helper.
25}