1 unstable release
new 0.1.0 | Mar 6, 2025 |
---|
#853 in Algorithms
62 downloads per month
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
Dependencies
~225–680KB
~16K SLoC