pub struct HealthRecord { /* private fields */ }Expand description
Per-endpoint health + breaker state (RFC 0018 §4.1). Every field is an atomic
so the record is shared (&self) across the call path without a lock.
Implementations§
Source§impl HealthRecord
impl HealthRecord
pub const fn new() -> HealthRecord
pub fn state(&self) -> BreakerState
pub fn consec_fail(&self) -> u32
pub fn total_calls(&self) -> u64
pub fn total_fail(&self) -> u64
Sourcepub fn error_rate(&self) -> f64
pub fn error_rate(&self) -> f64
Process-lifetime error rate (total_fail / total_calls); a windowed rate
is computed by the collector from the scraped counters (RFC 0018 §4.1).
pub fn ewma_latency_ms(&self) -> u64
pub fn last_err_kind(&self) -> ErrKind
pub fn last_ok_ms_ago(&self) -> Option<u64>
pub fn opened_ms_ago(&self) -> Option<u64>
Sourcepub fn cooldown(&self, cfg: &BreakerConfig) -> Duration
pub fn cooldown(&self, cfg: &BreakerConfig) -> Duration
The current cooldown for this endpoint (initial × 2^open_count, capped).
Sourcepub fn available(&self, cfg: &BreakerConfig) -> bool
pub fn available(&self, cfg: &BreakerConfig) -> bool
True if this endpoint is currently usable (not OPEN-and-cooling). Called
by attempt_order() (§3.3): an endpoint whose cooldown elapsed is
promoted to HALF-OPEN here so the next call probes it.
Sourcepub fn is_up(&self) -> bool
pub fn is_up(&self) -> bool
1 if the breaker is not OPEN (in rotation) — the agentd_intel_endpoint_up
gauge meaning (§4.3). Read-only (no promotion side effect).
Sourcepub fn record_success(&self, latency: Duration) -> Option<BreakerTransition>
pub fn record_success(&self, latency: Duration) -> Option<BreakerTransition>
Record a successful round-trip: reset the failure run, re-close the breaker, and fold the latency into the EWMA (alpha = 1/8). Returns the breaker transition that happened (for the §8 event / §4.4 emission).
Sourcepub fn record_failure(
&self,
kind: ErrKind,
cfg: &BreakerConfig,
) -> Option<BreakerTransition>
pub fn record_failure( &self, kind: ErrKind, cfg: &BreakerConfig, ) -> Option<BreakerTransition>
Record a failover-class failure: bump the run, stamp the error kind, and open the breaker if we crossed the threshold (or a HALF-OPEN probe failed). Returns the breaker transition (for the §8 event / §4.4 emission).