pub struct ShutdownController { /* private fields */ }Expand description
Shutdown controller that manages graceful shutdown
This is the central coordinator for shutdown operations. Clone this to share across tasks.
Implementations§
Source§impl ShutdownController
impl ShutdownController
Sourcepub fn with_timeout(drain_timeout: Duration) -> Self
pub fn with_timeout(drain_timeout: Duration) -> Self
Create a new shutdown controller with custom drain timeout
Sourcepub fn is_shutting_down(&self) -> bool
pub fn is_shutting_down(&self) -> bool
Check if shutdown has been initiated
Sourcepub fn state(&self) -> ShutdownState
pub fn state(&self) -> ShutdownState
Get the current shutdown state
Sourcepub fn state_receiver(&self) -> Receiver<ShutdownState>
pub fn state_receiver(&self) -> Receiver<ShutdownState>
Get a receiver for state changes
Sourcepub async fn initiate_shutdown(&self)
pub async fn initiate_shutdown(&self)
Initiate graceful shutdown
This method:
- Sets the shutdown flag
- Transitions to Draining state
- Notifies all subscribers
- Waits for connections to drain (with timeout)
- Transitions to Stopped state
Sourcepub async fn wait_for_shutdown(&self)
pub async fn wait_for_shutdown(&self)
Wait for the shutdown signal
Sourcepub fn connection_start(&self)
pub fn connection_start(&self)
Increment active connection count
Sourcepub fn connection_end(&self)
pub fn connection_end(&self)
Decrement active connection count
Sourcepub fn active_connections(&self) -> u64
pub fn active_connections(&self) -> u64
Get current active connection count
Sourcepub fn connection_guard(&self) -> ConnectionGuard
pub fn connection_guard(&self) -> ConnectionGuard
Create a connection guard that automatically decrements on drop
Sourcepub fn drain_timeout(&self) -> Duration
pub fn drain_timeout(&self) -> Duration
Get the drain timeout
Sourcepub fn shutdown_elapsed(&self) -> Option<Duration>
pub fn shutdown_elapsed(&self) -> Option<Duration>
Get time elapsed since shutdown started
Sourcepub fn retry_after_secs(&self) -> u64
pub fn retry_after_secs(&self) -> u64
Get Retry-After header value in seconds (for 503 responses)
Source§impl ShutdownController
impl ShutdownController
Sourcepub fn health_status(&self) -> HealthStatus
pub fn health_status(&self) -> HealthStatus
Get health status for health check endpoint
During shutdown, this returns unhealthy status with retry information.
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 moreAuto Trait Implementations§
impl Freeze for ShutdownController
impl !RefUnwindSafe for ShutdownController
impl Send for ShutdownController
impl Sync for ShutdownController
impl Unpin for ShutdownController
impl !UnwindSafe for ShutdownController
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more