This is an implementation of a failure detector that uses an adaptive accrual algorithm. The theory of this failure detector is taken from the paper A New Adaptive Accrual Failure Detector for Dependable Distributed Systems.
This failure detector is useful for detecting connections failures between nodes in distributed systems.
for documentation, view the API reference
go get github.com/andy2046/failured
package main
import (
"time"
"github.com/andy2046/failured"
)
func main() {
fd := failured.New()
closer := make(chan struct{})
// call RegisterHeartbeat every second
go func() {
for {
select {
case <-closer:
return
default:
}
time.Sleep(time.Second)
fd.RegisterHeartbeat()
}
}()
time.Sleep(3 * time.Second)
close(closer)
// check FailureProbability
p := fd.FailureProbability()
println("failure probability is", p)
}