pub struct SignalCoordinator { /* private fields */ }Expand description
Coordinates Unix signal handling across the application
Creates broadcast channels for shutdown and reload events that multiple components can subscribe to.
Implementations§
Source§impl SignalCoordinator
impl SignalCoordinator
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new signal coordinator
The coordinator doesn’t start handling signals until run() is called.
Sourcepub fn shutdown_receiver(&self) -> Receiver<()>
pub fn shutdown_receiver(&self) -> Receiver<()>
Get a receiver for shutdown events
Multiple receivers can be created. Each will receive the shutdown signal.
Sourcepub fn reload_receiver(&self) -> Receiver<()>
pub fn reload_receiver(&self) -> Receiver<()>
Get a receiver for reload events
Multiple receivers can be created. Each will receive reload signals.
Sourcepub fn signal_shutdown(&self)
pub fn signal_shutdown(&self)
Signal shutdown to all listeners
This can be called programmatically to trigger shutdown.
Sourcepub fn signal_reload(&self)
pub fn signal_reload(&self)
Signal reload to all listeners
This can be called programmatically to trigger config reload.
Sourcepub fn has_shutdown_receivers(&self) -> bool
pub fn has_shutdown_receivers(&self) -> bool
Check if any shutdown receivers are active
Sourcepub fn has_reload_receivers(&self) -> bool
pub fn has_reload_receivers(&self) -> bool
Check if any reload receivers are active
Sourcepub async fn run(self)
pub async fn run(self)
Run the signal handler
This should be spawned as an async task. It will run until a shutdown signal is received.
§Signals Handled
- SIGTERM: Initiates graceful shutdown
- SIGINT: Initiates graceful shutdown (Ctrl+C)
- SIGHUP: Triggers configuration reload
§Example
let coordinator = SignalCoordinator::new();
let mut shutdown_rx = coordinator.shutdown_receiver();
tokio::spawn(async move {
coordinator.run().await;
});Trait Implementations§
Auto Trait Implementations§
impl Freeze for SignalCoordinator
impl !RefUnwindSafe for SignalCoordinator
impl Send for SignalCoordinator
impl Sync for SignalCoordinator
impl Unpin for SignalCoordinator
impl UnsafeUnpin for SignalCoordinator
impl !UnwindSafe for SignalCoordinator
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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 moreSource§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>
T in a tonic::Request