Skip to main content

hyperlane_plugin_shutdown/
lib.rs

1//! hyperlane-plugin-shutdown
2//!
3//! Graceful shutdown coordinator plugin for Hyperlane providing OS signal
4//! arming (`SIGINT`/`SIGTERM`), lock-free in-flight draining via RAII
5//! [`ShutdownGuard`], LIFO async [`ShutdownCallback`] execution, and
6//! [`ServerControlHook`] integration.
7
8mod r#const;
9mod r#fn;
10mod r#impl;
11mod r#static;
12mod r#struct;
13mod r#trait;
14mod r#type;
15
16#[cfg(test)]
17#[path = "../tests/mod.rs"]
18mod tests;
19
20pub use {r#const::*, r#struct::*, r#trait::*, r#type::*};
21
22pub(crate) use {r#fn::*, r#static::*};
23
24use std::{
25    array::from_fn,
26    future::{Future, pending},
27    io,
28    pin::{Pin, pin},
29    sync::{
30        Arc, OnceLock,
31        atomic::{AtomicBool, AtomicUsize, Ordering, fence},
32    },
33    time::{Duration, Instant},
34};
35
36#[cfg(unix)]
37use hyperlane::tokio::signal::unix::{SignalKind, signal};
38
39use {
40    hyperlane::{
41        ServerControlHook,
42        tokio::{
43            select,
44            signal::ctrl_c,
45            spawn,
46            sync::{Notify, futures::Notified},
47            task::JoinHandle,
48            time::timeout,
49        },
50    },
51    lombok_macros::*,
52};