pub struct CriticalFailureState { /* private fields */ }Expand description
The owner-scoped authority for critical task failures.
One state is shared by the critical tasks of a component and by the monitor that handles them. Clones share the same record.
Implementations§
Source§impl CriticalFailureState
impl CriticalFailureState
Sourcepub fn record(
&self,
kind: CriticalFailureKind,
task_kind: TaskKind,
) -> CriticalFailure
pub fn record( &self, kind: CriticalFailureKind, task_kind: TaskKind, ) -> CriticalFailure
Records one failure and returns it.
The first unhandled failure stays pending, because it is the evidence a
handler takes with Self::handle. Later failures still advance the
sequence and the occurrence count, so a handler can tell that more than
one occurred, and they never replace the pending record.
Sourcepub fn pending(&self) -> Option<CriticalFailure>
pub fn pending(&self) -> Option<CriticalFailure>
Returns the pending failure without handling it.
Sourcepub fn handle(&self) -> Option<CriticalFailure>
pub fn handle(&self) -> Option<CriticalFailure>
Takes the pending failure, marking it handled.
Sourcepub fn occurrences(&self) -> u64
pub fn occurrences(&self) -> u64
Returns how many failures were recorded in this process.
Sourcepub async fn wait(&self) -> CriticalFailure
pub async fn wait(&self) -> CriticalFailure
Waits until a failure is pending and returns it without handling it.
Sourcepub fn subscribe(
&self,
capacity: usize,
) -> Result<CriticalFailureSubscription, RuntimeContractViolation>
pub fn subscribe( &self, capacity: usize, ) -> Result<CriticalFailureSubscription, RuntimeContractViolation>
Subscribes to bounded failure notifications.
The subscription is a signal, not the record: when the channel is full the
notification is dropped and Self::pending still reports the failure.
§Errors
Returns a contract violation when capacity is zero.
Sourcepub fn spawn_monitor<F>(
&self,
owner: &TaskSpawner,
name: impl Into<TaskName>,
on_failure: F,
) -> RuntimeResult<TaskId>
pub fn spawn_monitor<F>( &self, owner: &TaskSpawner, name: impl Into<TaskName>, on_failure: F, ) -> RuntimeResult<TaskId>
Spawns a monitor under owner that takes each pending failure and hands
it to on_failure.
owner must be an owner outside the group of the monitored tasks. A group
that became poisoned cannot spawn work, so a monitor inside it could never
run.
§Errors
Returns an error when owner is shutting down or closed.