|
| 1 | + |
| 2 | + |
| 3 | +# failured |
| 4 | +`import "github.com/andy2046/failured"` |
| 5 | + |
| 6 | +* [Overview](#pkg-overview) |
| 7 | +* [Index](#pkg-index) |
| 8 | +* [Subdirectories](#pkg-subdirectories) |
| 9 | + |
| 10 | +## <a name="pkg-overview">Overview</a> |
| 11 | +Package failured implements the Adaptive Accrual Failure Detector |
| 12 | + |
| 13 | +This package implements [A New Adaptive Accrual Failure Detector for Dependable Distributed Systems](<a href="https://dl.acm.org/citation.cfm?id=1244129">https://dl.acm.org/citation.cfm?id=1244129</a>) |
| 14 | + |
| 15 | +To use the failure detector, you need a heartbeat loop that will |
| 16 | +call RegisterHeartbeat() at regular intervals. At any point, you can call FailureProbability() which will |
| 17 | +report the suspicion level since the last time RegisterHeartbeat() was called. |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +## <a name="pkg-index">Index</a> |
| 23 | +* [Variables](#pkg-variables) |
| 24 | +* [type Config](#Config) |
| 25 | +* [type Detector](#Detector) |
| 26 | + * [func New(options ...Option) *Detector](#New) |
| 27 | + * [func (d *Detector) CheckFailure(now ...int64) bool](#Detector.CheckFailure) |
| 28 | + * [func (d *Detector) FailureProbability(now ...int64) float64](#Detector.FailureProbability) |
| 29 | + * [func (d *Detector) RegisterHeartbeat(now ...int64)](#Detector.RegisterHeartbeat) |
| 30 | +* [type Option](#Option) |
| 31 | + |
| 32 | + |
| 33 | +#### <a name="pkg-files">Package files</a> |
| 34 | +[failured.go](/src/github.com/andy2046/failured/failured.go) |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +## <a name="pkg-variables">Variables</a> |
| 39 | +``` go |
| 40 | +var ( |
| 41 | + // DefaultConfig is the default Detector Config. |
| 42 | + DefaultConfig = Config{ |
| 43 | + WindowSize: 1000, |
| 44 | + Factor: 0.9, |
| 45 | + FailureThreshold: 0.5, |
| 46 | + } |
| 47 | +) |
| 48 | +``` |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +## <a name="Config">type</a> [Config](/src/target/failured.go?s=1129:1275#L46) |
| 53 | +``` go |
| 54 | +type Config struct { |
| 55 | + // max size of inter-arrival time list |
| 56 | + WindowSize uint64 |
| 57 | + // a scaling factor |
| 58 | + Factor float64 |
| 59 | + |
| 60 | + FailureThreshold float64 |
| 61 | +} |
| 62 | +``` |
| 63 | +Config used to init Detector. |
| 64 | + |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | + |
| 73 | + |
| 74 | +## <a name="Detector">type</a> [Detector](/src/target/failured.go?s=752:1092#L29) |
| 75 | +``` go |
| 76 | +type Detector struct { |
| 77 | + // contains filtered or unexported fields |
| 78 | +} |
| 79 | +``` |
| 80 | +Detector is a failure detector. |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | +### <a name="New">func</a> [New](/src/target/failured.go?s=1558:1595#L69) |
| 89 | +``` go |
| 90 | +func New(options ...Option) *Detector |
| 91 | +``` |
| 92 | +New returns a new failure detector. |
| 93 | + |
| 94 | + |
| 95 | + |
| 96 | + |
| 97 | + |
| 98 | +### <a name="Detector.CheckFailure">func</a> (\*Detector) [CheckFailure](/src/target/failured.go?s=3186:3236#L145) |
| 99 | +``` go |
| 100 | +func (d *Detector) CheckFailure(now ...int64) bool |
| 101 | +``` |
| 102 | +CheckFailure returns true if `FailureProbability` is |
| 103 | +equal to or higher than `FailureThreshold`. |
| 104 | +`now` is the current time in Microseconds. |
| 105 | + |
| 106 | + |
| 107 | + |
| 108 | + |
| 109 | +### <a name="Detector.FailureProbability">func</a> (\*Detector) [FailureProbability](/src/target/failured.go?s=2554:2613#L112) |
| 110 | +``` go |
| 111 | +func (d *Detector) FailureProbability(now ...int64) float64 |
| 112 | +``` |
| 113 | +FailureProbability calculates the suspicion level at time `now` |
| 114 | +that the remote end has failed. |
| 115 | +`now` is the current time in Milliseconds, |
| 116 | +default to time.Now() in Milliseconds. |
| 117 | + |
| 118 | + |
| 119 | + |
| 120 | + |
| 121 | +### <a name="Detector.RegisterHeartbeat">func</a> (\*Detector) [RegisterHeartbeat](/src/target/failured.go?s=1998:2048#L86) |
| 122 | +``` go |
| 123 | +func (d *Detector) RegisterHeartbeat(now ...int64) |
| 124 | +``` |
| 125 | +RegisterHeartbeat registers a heartbeat at time `now`. |
| 126 | +`now` is the time in Milliseconds at which the heartbeat was received, |
| 127 | +default to time.Now() in Milliseconds. |
| 128 | + |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | +## <a name="Option">type</a> [Option](/src/target/failured.go?s=1324:1352#L56) |
| 133 | +``` go |
| 134 | +type Option = func(*Config) error |
| 135 | +``` |
| 136 | +Option applies config to Detector Config. |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | + |
| 144 | + |
| 145 | + |
| 146 | + |
| 147 | + |
| 148 | + |
| 149 | + |
| 150 | + |
| 151 | +- - - |
| 152 | +Generated by [godoc2md](http://godoc.org/github.com/davecheney/godoc2md) |
0 commit comments