util

package
v0.0.0-...-b2761b6 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2014 License: GPL-3.0, GPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SwapTimeouts

func SwapTimeouts(newTimeouts []time.Duration) (oldTimeouts []time.Duration)

for testing: change the default timeouts for the provided ones, returning the defaults (the idea being you reset them on test teardown)

func Timeouts

func Timeouts() []time.Duration

retrieve the list of timeouts used for exponential backoff

Types

type AutoRedialer

type AutoRedialer interface {
	Redial() uint32 // Redial keeps on calling Dial until it stops returning an error.
	Stop()          // Stop shuts down the given AutoRedialer, if it is still retrying.
}

An AutoRedialer's Redial() method retries its dialer's Dial() method until it stops returning an error. It does exponential (optionally jitter'ed) backoff.

func NewAutoRedialer

func NewAutoRedialer(dialer Dialer) AutoRedialer

returns a stoppable AutoRedialer using the provided Dialer. If the Dialer is also a Jitterer, the backoff will be jittered.

type Dialer

type Dialer interface {
	Dial() error
}

A Dialer is an object that knows how to establish a connection, and where you'd usually want some kind of back off if that connection fails.

type Jitterer

type Jitterer interface {
	Dialer
	Jitter(time.Duration) time.Duration
}

A Jitterer is a Dialer that wants to vary the backoff a little (to avoid a thundering herd, for example).

Jump to

Keyboard shortcuts

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