accrual

package module
v0.0.0-...-2ade2d3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2016 License: MIT Imports: 4 Imported by: 0

README

φ accrual failure detector

A Go implementation of the φ Accrual Failure Detector.

Documentation

Overview

Package accrual is an implementation of the φ Accrual Failure Detector. For details see: https://dspace.jaist.ac.jp/dspace/bitstream/10119/4784/1/IS-RR-2004-010.pdf

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector represents a φ-failure detector.

Example
w := NewMemoryWindow(10)
d := NewDetector(1, w)
d.Heartbeat()
if d.Failed() {
	fmt.Println("Failure dectected")
}
Output:

func NewDetector

func NewDetector(threshold float64, w Window) *Detector

NewDetector creates a new detector with the given threshold and a window.

func (*Detector) Failed

func (d *Detector) Failed() bool

Failed returns if there is a potential failure.

func (*Detector) Heartbeat

func (d *Detector) Heartbeat()

Heartbeat records a heartbeat.

type Window

type Window interface {
	Record()
	Last() time.Time
	Distribution() []int64
}

Window is the interface that wraps interval storages.

func NewMemoryWindow

func NewMemoryWindow(size int) Window

NewMemoryWindow creates a new in-memory window.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL