states

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2019 License: MPL-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package states provides peer state tracking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PeerState

type PeerState interface {
	// Heartbeat is called every check cycle to indicate if the peer was seen
	// recently or not. A Heartbeat function should return the new PeerState
	// and a bool to indicate if change was noteworthy. Noteworthy-ness is defined
	// by the states themselves but generally should only be true for changes
	// from an intermediate state to the next state and not from an intermediate
	// state to a return state or a state to itself.
	Heartbeat(seen bool) (PeerState, bool)
	// String describes the PeerState's current state as a string.
	String() string
}

PeerState is an interface describing a peer that responds to heartbeats by changing state. All PeerStates can represent their current state as a string. State changes can be marked as notable or not notable by returning a bool from the heartbeat function alongside the new state.

TODO(@cpu): Make this an internal export

func NewPeer

func NewPeer(upThreshold, downThreshold uint) PeerState

NewPeer returns a PeerState that will transition states based on the provided thresholds. The returned PeerState represents a down connection that must receive downThreshold seen events to transition to up.

TODO(@cpu): Make this an internal export TODO(@cpu): Describe lifecycle based on upThreshold/downThreshold

Jump to

Keyboard shortcuts

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