pub struct GracefulShutdown { /* private fields */ }Expand description
Builder for graceful shutdown.
Implementations§
Source§impl GracefulShutdown
impl GracefulShutdown
Sourcepub fn new(receiver: ShutdownReceiver) -> Self
pub fn new(receiver: ShutdownReceiver) -> Self
Create a new graceful shutdown builder.
Sourcepub fn grace_period(self, duration: Duration) -> Self
pub fn grace_period(self, duration: Duration) -> Self
Set the grace period for in-flight requests.
Sourcepub fn cleanup_budget(self, budget: Budget) -> Self
pub fn cleanup_budget(self, budget: Budget) -> Self
Set the cleanup budget.
Sourcepub fn log_events(self, enabled: bool) -> Self
pub fn log_events(self, enabled: bool) -> Self
Enable or disable event logging.
Sourcepub async fn run<F, T>(self, fut: F) -> ShutdownOutcome<T>where
F: Future<Output = T>,
pub async fn run<F, T>(self, fut: F) -> ShutdownOutcome<T>where
F: Future<Output = T>,
Run a future with graceful shutdown support.
Returns when either:
- The future completes normally
- Graceful shutdown completes
- Forced shutdown is triggered
Note: This is a simplified implementation. For production use with
proper concurrent select behavior, consider using the futures crate’s
select macro or similar.
Sourcepub fn config(&self) -> &GracefulConfig
pub fn config(&self) -> &GracefulConfig
Get the configuration.
Auto Trait Implementations§
impl Freeze for GracefulShutdown
impl !RefUnwindSafe for GracefulShutdown
impl Send for GracefulShutdown
impl Sync for GracefulShutdown
impl Unpin for GracefulShutdown
impl !UnwindSafe for GracefulShutdown
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).