pub struct ShutdownCoordinator { /* private fields */ }Expand description
Owns the Tokio adapter task set for one application runtime.
Implementations§
Source§impl ShutdownCoordinator
impl ShutdownCoordinator
Sourcepub fn new(
shutdown_deadline: ShutdownDeadline,
task_join_deadline: TaskJoinDeadline,
telemetry_deadline: TelemetryFlushDeadline,
) -> Result<Self, ShutdownError>
pub fn new( shutdown_deadline: ShutdownDeadline, task_join_deadline: TaskJoinDeadline, telemetry_deadline: TelemetryFlushDeadline, ) -> Result<Self, ShutdownError>
Constructs an empty application-owned coordinator.
§Errors
Returns ShutdownError::TaskJoinExceedsShutdown when the supplied
join budget exceeds the total correctness budget.
Sourcepub fn with_event_sink(self, sink: Arc<dyn TelemetryEventSink>) -> Self
pub fn with_event_sink(self, sink: Arc<dyn TelemetryEventSink>) -> Self
Attaches a non-authoritative, panic-isolated telemetry sink.
Sourcepub fn signal(&self) -> ShutdownSignal
pub fn signal(&self) -> ShutdownSignal
Returns the application-owned handle used by API or signal adapters.
Sourcepub fn spawn<F>(
&mut self,
phase: ShutdownTaskPhase,
future: F,
) -> Result<(), ShutdownError>
pub fn spawn<F>( &mut self, phase: ShutdownTaskPhase, future: F, ) -> Result<(), ShutdownError>
Spawns one task into the coordinator’s structured ownership set.
Panics are caught at this boundary and counted in the shutdown report. The coordinator never detaches or force-aborts an in-flight task.
§Errors
Returns ShutdownError::ShuttingDown after intake stops.
Sourcepub async fn shutdown<P, PF, T, TF, C, CF>(
&mut self,
persist: P,
flush_telemetry: T,
close_repository: C,
) -> ShutdownReportwhere
P: FnOnce() -> PF,
PF: Future<Output = Result<(), ShutdownHookError>>,
T: FnOnce() -> TF,
TF: Future<Output = Result<u64, ShutdownHookError>>,
C: FnOnce() -> CF,
CF: Future<Output = Result<(), ShutdownHookError>>,
pub async fn shutdown<P, PF, T, TF, C, CF>(
&mut self,
persist: P,
flush_telemetry: T,
close_repository: C,
) -> ShutdownReportwhere
P: FnOnce() -> PF,
PF: Future<Output = Result<(), ShutdownHookError>>,
T: FnOnce() -> TF,
TF: Future<Output = Result<u64, ShutdownHookError>>,
C: FnOnce() -> CF,
CF: Future<Output = Result<(), ShutdownHookError>>,
Runs the fixed shutdown sequence.
The persistence closure runs after joining, telemetry uses its separate deadline, and repository close runs last. Closure errors are reported without changing the previously established drain result. The persistence closure must enforce its repository statement and commit timeouts; this coordinator never cancels an in-flight persistence future at the outer correctness deadline.
Trait Implementations§
Source§impl Debug for ShutdownCoordinator
impl Debug for ShutdownCoordinator
Auto Trait Implementations§
impl !RefUnwindSafe for ShutdownCoordinator
impl !UnwindSafe for ShutdownCoordinator
impl Freeze for ShutdownCoordinator
impl Send for ShutdownCoordinator
impl Sync for ShutdownCoordinator
impl Unpin for ShutdownCoordinator
impl UnsafeUnpin for ShutdownCoordinator
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> 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