backoff

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2020 License: Apache-2.0 Imports: 4 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FiveSec = BackoffPolicy{
	[]int{500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000},
}

FiveSec is a backoff policy ranging up to 5 seconds.

View Source
var TwentySec = BackoffPolicy{
	[]int{
		500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000,
		5500, 5750, 6000, 6500, 7000, 7500, 8000, 8500, 9000, 9500, 10000,
		10500, 10750, 11000, 11500, 12000, 12500, 13000, 13500, 14000, 14500, 15000,
		15500, 15750, 16000, 16500, 17000, 17500, 18000, 18500, 19000, 19500, 20000,
	},
}

TwentySec is a backoff policy ranging up to 20 seconds

Functions

This section is empty.

Types

type BackoffPolicy

type BackoffPolicy struct {
	Millis []int
}

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

func (BackoffPolicy) Duration

func (b BackoffPolicy) 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.

func (BackoffPolicy) InterruptableSleep

func (b BackoffPolicy) InterruptableSleep(ctx context.Context, n int) error

InterruptableSleep is DEPRECATED see InterruptibleSleep

func (*BackoffPolicy) InterruptibleSleep added in v0.13.1

func (b *BackoffPolicy) InterruptibleSleep(ctx context.Context, n int) error

InterruptibleSleep sleep for the duration of the n'th wait cycle in a way that can be interrupted by the context. An error is returned if the context cancels the sleep

Jump to

Keyboard shortcuts

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