strut_core/
lib.rs

1#![doc = include_str!("../README.md")]
2#![deny(missing_docs)]
3#![cfg_attr(test, deny(warnings))]
4
5/// Application profile.
6mod profile;
7pub use self::profile::AppProfile;
8
9/// Application context.
10mod context;
11pub use self::context::AppContext;
12
13/// Application replica facade.
14mod replica;
15pub use self::replica::lifetime_id::{Glued, Hyphenated, LifetimeId, Underscored};
16pub use self::replica::AppReplica;
17
18/// Application spindown registry & tokens.
19mod spindown;
20pub use self::spindown::{token::AppSpindownToken, AppSpindown};
21
22/// Implements a [`Pivot`] facade for centralized resolution of the pivot directory
23mod pivot;
24pub use self::pivot::Pivot;
25
26/// Globally recognized field name that, when present in a `tracing` macro call,
27/// should trigger an event for an external alerting system.
28pub const ALERT_FIELD_NAME: &str = "alert";
29
30/// [Terminates](AppContext::terminate) the global [`AppContext`] and waits for
31/// [`AppSpindown`] to complete.
32///
33/// This is effectively the global shutdown&clean-up routine for all workloads
34/// that integrate with the Strut family of crates via [`AppContext`] and
35/// [`AppSpindown`].
36///
37/// ## Usage
38///
39/// When using any of the Strut components without the `strut` crate itself,
40/// await on this function as a last thing before completing the main
41/// application logic.
42pub async fn strut_shutdown() {
43    // Terminate the global application context
44    AppContext::terminate();
45
46    // Wait for the registered spindown workloads to finish
47    AppSpindown::completed().await;
48}