pub struct ShutdownController { /* private fields */ }Expand description
Controller for coordinating graceful shutdown.
Provides mechanisms to:
- Subscribe to shutdown signals
- Trigger shutdown programmatically
- Wait for in-flight operations to complete
- Set shutdown timeout
Implementations§
Source§impl ShutdownController
impl ShutdownController
Sourcepub fn subscribe(&self) -> Receiver<bool>
pub fn subscribe(&self) -> Receiver<bool>
Subscribe to shutdown notifications.
Returns a receiver that will be notified when shutdown is initiated.
Sourcepub fn is_shutdown(&self) -> bool
pub fn is_shutdown(&self) -> bool
Check if shutdown has been initiated.
Sourcepub fn shutdown_signal(&self) -> ShutdownSignal
pub fn shutdown_signal(&self) -> ShutdownSignal
Get a future that resolves when shutdown is initiated.
Sourcepub async fn shutdown(&self, grace_period: Duration) -> bool
pub async fn shutdown(&self, grace_period: Duration) -> bool
Initiate graceful shutdown.
This will:
- Set the shutdown flag
- Notify all subscribers
- Wait for active operations to complete (with timeout)
Returns true if all operations completed gracefully, false if timed out.
Sourcepub fn register_operation(&self) -> OperationGuard
pub fn register_operation(&self) -> OperationGuard
Register an active operation.
Returns a guard that decrements the counter when dropped.
Sourcepub fn active_operations(&self) -> usize
pub fn active_operations(&self) -> usize
Get the number of active operations.
Trait Implementations§
Source§impl Clone for ShutdownController
impl Clone for ShutdownController
Source§impl Debug for ShutdownController
impl Debug for ShutdownController
Auto Trait Implementations§
impl !RefUnwindSafe for ShutdownController
impl !UnwindSafe for ShutdownController
impl Freeze for ShutdownController
impl Send for ShutdownController
impl Sync for ShutdownController
impl Unpin for ShutdownController
impl UnsafeUnpin 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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request