Skip to main content

HealthFlag

Struct HealthFlag 

Source
pub struct HealthFlag(/* private fields */);
Expand description

A cloneable handle to one surface’s health. Level and counter reads are lock-free; the reason string lives behind a Mutex whose only invariant is the single Option it holds, so recovering a poisoned lock with into_inner is sound (there is no cross-field state to leave half-mutated).

Implementations§

Source§

impl HealthFlag

Source

pub fn new(tcb_critical: bool) -> Self

Create a flag in the HealthLevel::Healthy state. tcb_critical marks a surface whose degradation must fail evaluations closed.

Source

pub fn record_ok(&self, now_ms: u64)

Record a completed unit of work. Resets the consecutive-failure counter and stamps liveness, but never lowers a tripped level.

Source

pub fn record_failure( &self, reason: impl Into<String>, now_ms: u64, trip_after: u32, ) -> u32

Record a restart-worthy failure and return the new consecutive count. Trips to HealthLevel::Degraded once the count reaches trip_after, and never downgrades. trip_after == 0 trips on the first failure.

Source

pub fn escalate_failed(&self, now_ms: u64)

Terminal escalation: the restart budget is exhausted and the supervisor has stopped respawning. Raises the level to HealthLevel::Failed.

Source

pub fn level(&self) -> HealthLevel

The current severity level.

Source

pub fn tcb_critical(&self) -> bool

Whether this surface is TCB-critical.

Source

pub fn is_serving_closed(&self) -> bool

True when the surface must fail closed: TCB-critical and not HealthLevel::Healthy. Read on the pre-dispatch path.

Source

pub fn clear(&self, now_ms: u64)

The only path back to HealthLevel::Healthy: an explicit operator recovery. Clears the reason and resets the consecutive-failure counter; the cumulative restart_total is preserved so the history of the incident is not erased.

Source

pub fn snapshot(&self) -> HealthSnapshot

Point-in-time view for operator surfaces and telemetry exporters.

Trait Implementations§

Source§

impl Clone for HealthFlag

Source§

fn clone(&self) -> HealthFlag

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.