lib

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// SeededSecurely is set to true if a cryptographically secure seed
	// was used to initialize rand.  When false, the start time is used
	// as a seed.
	SeededSecurely bool
)

Functions

func AbsInt added in v0.7.0

func AbsInt(a int) int

func ComputeDistance added in v0.8.0

func ComputeDistance(a *coordinate.Coordinate, b *coordinate.Coordinate) float64

ComputeDistance returns the distance between the two network coordinates in seconds. If either of the coordinates is nil then this will return positive infinity.

func DurationMinusBuffer added in v0.7.0

func DurationMinusBuffer(intv time.Duration, buffer time.Duration, jitter int64) time.Duration

DurationMinusBuffer returns a duration, minus a buffer and jitter subtracted from the duration. This function is used primarily for servicing Consul TTL Checks in advance of the TTL.

func DurationMinusBufferDomain added in v0.7.0

func DurationMinusBufferDomain(intv time.Duration, buffer time.Duration, jitter int64) (min time.Duration, max time.Duration)

DurationMinusBufferDomain returns the domain of valid durations from a call to DurationMinusBuffer. This function is used to check user specified input values to DurationMinusBuffer.

func EnsurePath added in v0.7.3

func EnsurePath(path string, dir bool) error

EnsurePath is used to make sure a path exists

func GenerateCoordinate added in v0.8.0

func GenerateCoordinate(rtt time.Duration) *coordinate.Coordinate

GenerateCoordinate creates a new coordinate with the given distance from the origin. This should only be used for tests.

func IsErrEOF added in v1.0.0

func IsErrEOF(err error) bool

IsErrEOF returns true if we get an EOF error from the socket itself, or an EOF equivalent error from yamux.

func MaxInt added in v0.7.0

func MaxInt(a, b int) int

func MinInt added in v0.7.0

func MinInt(a, b int) int

func RandomStagger

func RandomStagger(intv time.Duration) time.Duration

RandomStagger returns an interval between 0 and the duration

func RateScaledInterval

func RateScaledInterval(rate float64, min time.Duration, n int) time.Duration

RateScaledInterval is used to choose an interval to perform an action in order to target an aggregate number of actions per second across the whole cluster.

func SeedMathRand

func SeedMathRand()

SeedMathRand provides weak, but guaranteed seeding, which is better than running with Go's default seed of 1. A call to SeedMathRand() is expected to be called via init(), but never a second time.

func SerfDefaultConfig added in v1.0.2

func SerfDefaultConfig() *serf.Config

SerfDefaultConfig returns a Consul-flavored Serf default configuration, suitable as a basis for a LAN, WAN, segment, or area.

func StrContains

func StrContains(l []string, s string) bool

StrContains checks if a list contains a string

Types

type CoordinateSet added in v0.9.3

type CoordinateSet map[string]*coordinate.Coordinate

CoordinateSet holds all the coordinates for a given node, indexed by network segment name.

func (CoordinateSet) Intersect added in v0.9.3

Intersect tries to return a pair of coordinates which are compatible with the current set and a given set. We employ some special knowledge about network segments to avoid doing a full intersection, since this is in several hot paths. This might return nil for either coordinate in the output pair if an intersection cannot be found. The ComputeDistance function above is designed to deal with that.

Directories

Path Synopsis
Package freeport provides a helper for allocating free ports across multiple processes on the same machine.
Package freeport provides a helper for allocating free ports across multiple processes on the same machine.

Jump to

Keyboard shortcuts

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