backoff

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

package backoff implemenets policies for waiting differente ammounts of times when retrying something.

Taken from Peter Teichman's post on http://blog.gopheracademy.com/advent-2014/backoff/

Index

Constants

This section is empty.

Variables

View Source
var (
	// Default is a backoff policy ranging up to 5 seconds.
	Default = IncreasePolicy{
		[]int{0, 10, 10, 100, 100, 500, 500, 3000, 3000, 5000},
	}

	Random = RandomPolicy{10 * time.Second}
)

Functions

This section is empty.

Types

type Backoff

type Backoff interface {
	Duration(n int) time.Duration
}

type IncreasePolicy

type IncreasePolicy struct {
	Millis []int
}

IncreasePolicy implements a backoff policy, randomizing its delays and saturating at the final value in Millis.

func (IncreasePolicy) Duration

func (b IncreasePolicy) Duration(n int) time.Duration

Duration returns the time duration of the n'th wait cycle in a backoff policy. This is b.Millis[n], randomized to avoid thundering herds.

type RandomPolicy

type RandomPolicy struct {
	Max time.Duration
}

func (RandomPolicy) Duration

func (b RandomPolicy) Duration(n int) time.Duration

Jump to

Keyboard shortcuts

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