1 unstable release
0.1.0 | Mar 6, 2025 |
---|
#1035 in Algorithms
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
~215–660KB
~15K SLoC