pub struct ShutdownController { /* private fields */ }Expand description
Controller for initiating and coordinating shutdown.
Create one controller per server and share it via subscribe().
Implementations§
Source§impl ShutdownController
impl ShutdownController
Sourcepub fn subscribe(&self) -> ShutdownReceiver
pub fn subscribe(&self) -> ShutdownReceiver
Create a receiver to wait for shutdown signals.
Sourcepub fn phase(&self) -> ShutdownPhase
pub fn phase(&self) -> ShutdownPhase
Get the current shutdown phase.
Sourcepub fn is_shutting_down(&self) -> bool
pub fn is_shutting_down(&self) -> bool
Check if shutdown has been initiated.
Sourcepub fn shutdown(&self)
pub fn shutdown(&self)
Initiate graceful shutdown.
This begins the shutdown sequence. If shutdown is already in progress, calling this again triggers forced shutdown.
Sourcepub fn force_shutdown(&self)
pub fn force_shutdown(&self)
Force immediate shutdown without grace period.
Sourcepub fn advance_phase(&self) -> bool
pub fn advance_phase(&self) -> bool
Advance to the next shutdown phase.
Returns true if the phase was advanced.
Sourcepub fn register_hook<F>(&self, hook: F)
pub fn register_hook<F>(&self, hook: F)
Register a shutdown hook to run during the RunningHooks phase.
Hooks run in LIFO order (last registered runs first).
Sourcepub fn register_async_hook<F, Fut>(&self, hook: F)
pub fn register_async_hook<F, Fut>(&self, hook: F)
Register an async shutdown hook.
Sourcepub fn pop_hook(&self) -> Option<ShutdownHook>
pub fn pop_hook(&self) -> Option<ShutdownHook>
Pop and return the next shutdown hook to run.
Returns None when all hooks have been run.
Sourcepub fn hook_count(&self) -> usize
pub fn hook_count(&self) -> usize
Returns the number of registered hooks.
Sourcepub fn track_request(&self) -> InFlightGuard
pub fn track_request(&self) -> InFlightGuard
Track a new in-flight request.
Returns a guard that decrements the count when dropped.
Sourcepub fn in_flight_count(&self) -> usize
pub fn in_flight_count(&self) -> usize
Get the current in-flight request count.
Trait Implementations§
Source§impl Clone for ShutdownController
impl Clone for ShutdownController
Source§fn clone(&self) -> ShutdownController
fn clone(&self) -> ShutdownController
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more