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
impl HealthFlag
Sourcepub fn new(tcb_critical: bool) -> Self
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.
Sourcepub fn record_ok(&self, now_ms: u64)
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.
Sourcepub fn record_failure(
&self,
reason: impl Into<String>,
now_ms: u64,
trip_after: u32,
) -> u32
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.
Sourcepub fn escalate_failed(&self, now_ms: u64)
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.
Sourcepub fn level(&self) -> HealthLevel
pub fn level(&self) -> HealthLevel
The current severity level.
Sourcepub fn tcb_critical(&self) -> bool
pub fn tcb_critical(&self) -> bool
Whether this surface is TCB-critical.
Sourcepub fn is_serving_closed(&self) -> bool
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.
Sourcepub fn clear(&self, now_ms: u64)
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.
Sourcepub fn snapshot(&self) -> HealthSnapshot
pub fn snapshot(&self) -> HealthSnapshot
Point-in-time view for operator surfaces and telemetry exporters.
Trait Implementations§
Source§impl Clone for HealthFlag
impl Clone for HealthFlag
Source§fn clone(&self) -> HealthFlag
fn clone(&self) -> HealthFlag
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more