pub struct Shutdown {
pub handle: Handle,
pub grace_period: Option<Duration>,
}
axum
only.Expand description
Axum server shutdown coordinator.
Clones will retain the same coordination.
Fields§
§handle: Handle
Axum server handle.
Clones will retain the same coordination.
grace_period: Option<Duration>
Grace period. None means indefinite.
Implementations§
Source§impl Shutdown
impl Shutdown
Sourcepub fn shutdown_now(&self)
pub fn shutdown_now(&self)
Shutdown now (ignore grace period).
Sourcepub fn cancellation_token(&self) -> (CancellationToken, JoinHandle<()>)
pub fn cancellation_token(&self) -> (CancellationToken, JoinHandle<()>)
Get a CancellationToken.
Call CancellationToken::cancel to shutdown.
It’s best not to call this function more than once, as it spawns a listener task. If you need several tokens, clone the one you get here.
Also returns the JoinHandle for the listener task.
Sourcepub fn on_channel(&self) -> (Sender<()>, JoinHandle<()>)
pub fn on_channel(&self) -> (Sender<()>, JoinHandle<()>)
Shutdown on channel send.
Call Sender::send to shutdown.
It’s best not to call this function more than once, as it spawns a listener task. If you need several senders, clone the one you get here.
Also returns the JoinHandle for the listener task.
Sourcepub fn on_signals(&self) -> Result<JoinHandle<()>>
pub fn on_signals(&self) -> Result<JoinHandle<()>>
Shutdown on signals.
Returns the JoinHandle for the listener task.