failured
August 1, 2021 ยท View on GitHub
import "github.com/andy2046/failured"
Overview
Package failured implements the Adaptive Accrual Failure Detector
This package implements [A New Adaptive Accrual Failure Detector for Dependable Distributed Systems](https://dl.acm.org/citation.cfm?id=1244129)
To use the failure detector, you need a heartbeat loop that will call RegisterHeartbeat() at regular intervals. At any point, you can call FailureProbability() which will report the suspicion level since the last time RegisterHeartbeat() was called.
Index
Package files
Variables
var (
// DefaultConfig is the default Detector Config.
DefaultConfig = Config{
WindowSize: 1000,
Factor: 0.9,
FailureThreshold: 0.5,
}
)
type Config
type Config struct {
// max size of inter-arrival time list
WindowSize uint64
// a scaling factor
Factor float64
FailureThreshold float64
}
Config used to init Detector.
type Detector
type Detector struct {
// contains filtered or unexported fields
}
Detector is a failure detector.
func New
func New(options ...Option) *Detector
New returns a new failure detector.
func (*Detector) CheckFailure
func (d *Detector) CheckFailure(now ...int64) bool
CheckFailure returns true if FailureProbability is
equal to or higher than FailureThreshold.
now is the current time in Microseconds.
func (*Detector) FailureProbability
func (d *Detector) FailureProbability(now ...int64) float64
FailureProbability calculates the suspicion level at time now
that the remote end has failed.
now is the current time in Milliseconds,
default to time.Now() in Milliseconds.
func (*Detector) RegisterHeartbeat
func (d *Detector) RegisterHeartbeat(now ...int64)
RegisterHeartbeat registers a heartbeat at time now.
now is the time in Milliseconds at which the heartbeat was received,
default to time.Now() in Milliseconds.
type Option
type Option = func(*Config) error
Option applies config to Detector Config.
Generated by godoc2md