1 unstable release

new 0.1.0 Mar 6, 2025

#853 in Algorithms

Download history 62/week @ 2025-03-01

62 downloads per month

Apache-2.0

23KB
455 lines

Phi Accrual Failure Detector

A port of Apache Pekko implementation of Phi Accrual Failure Detector.

Usage

Adding dependency:

[dependencies]
phi-accrual-failure-detector = "0.1"

Example:

let detector = UnsyncDetector::default();

detector.heartbeat();
thread::sleep(Duration::from_millis(1000));

detector.heartbeat();
thread::sleep(Duration::from_millis(1000));

detector.heartbeat();
thread::sleep(Duration::from_millis(1000));

// The resource is available when receiving regular heartbeats.
println!("is available: {}", detector.is_available());
assert!(detector.is_available());

thread::sleep(Duration::from_millis(4000));

// The resource is no longer available, since it's missed a few heartbeats.
println!("is available: {}", detector.is_available());
assert!(!detector.is_available());

License

Apache 2.0

Dependencies

~225–680KB
~16K SLoC