Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket holds counts of failures and successes
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window maintains a ring of buckets and increments the failure and success counts of the current bucket. Once a specified time has elapsed, it will advance to the next bucket, reseting its counts. This allows the keeping of rolling statistics on the counts.
func New ¶
New creates a new window. windowTime is the time covering the entire window. windowBuckets is the number of buckets the window is divided into. An example: a 10 second window with 10 buckets will have 10 buckets covering 1 second each.
func (*Window) ErrorRate ¶
ErrorRate returns the error rate calculated over all buckets, expressed as a floating point number (e.g. 0.9 for 90%)