pub struct PhiAccrualState {
pub inter_arrival_history: VecDeque<u64>,
pub history_capacity: usize,
pub threshold_phi: f64,
pub down_phi: f64,
}Expand description
φ-accrual failure detector per direct chain neighbor. Heartbeat = any wire round-trip in the last window; rising φ indicates the peer is silent relative to its historical inter-arrival distribution.
Implementation per Hayashibara et al. - exponential approximation of the empirical inter-arrival distribution. The threshold defaults to 8 (Cassandra / Akka conservative).
Fields§
§inter_arrival_history: VecDeque<u64>Recent inter-arrival times of heartbeats, nanoseconds.
VecDeque so eviction at capacity is
O(1) pop_front instead of O(n) Vec::remove(0) memmove.
At history_capacity = 1000 and per-heartbeat ingest, the
quadratic cost dominated when φ-accrual ran on dozens of
peers in steady state.
history_capacity: usizeCapacity of the rolling history.
threshold_phi: f64Suspicion threshold; φ > this → peer is suspect.
down_phi: f64Hard-down threshold; φ > this → peer is down.
Implementations§
Source§impl PhiAccrualState
impl PhiAccrualState
Sourcepub fn record_heartbeat(&mut self, now_ns: u64, last_seen_at_ns: u64)
pub fn record_heartbeat(&mut self, now_ns: u64, last_seen_at_ns: u64)
Record a heartbeat at now_ns given the prior heartbeat at
last_seen_at_ns. The inter-arrival time enters the rolling
history (oldest sample evicted at capacity).
Sourcepub fn phi(&self, now_ns: u64, last_seen_at_ns: u64) -> f64
pub fn phi(&self, now_ns: u64, last_seen_at_ns: u64) -> f64
Compute current suspicion level φ. Returns 0.0 when no history is available (i.e., no heartbeats yet - the peer is assumed alive on the first contact).
Sourcepub fn is_suspect(&self, now_ns: u64, last_seen_at_ns: u64) -> bool
pub fn is_suspect(&self, now_ns: u64, last_seen_at_ns: u64) -> bool
true once φ crosses Self::threshold_phi.
Trait Implementations§
Source§impl Clone for PhiAccrualState
impl Clone for PhiAccrualState
Source§fn clone(&self) -> PhiAccrualState
fn clone(&self) -> PhiAccrualState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PhiAccrualState
impl Debug for PhiAccrualState
Auto Trait Implementations§
impl Freeze for PhiAccrualState
impl RefUnwindSafe for PhiAccrualState
impl Send for PhiAccrualState
impl Sync for PhiAccrualState
impl Unpin for PhiAccrualState
impl UnsafeUnpin for PhiAccrualState
impl UnwindSafe for PhiAccrualState
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedComponent for T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request