backoff

package
v2.5.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2017 License: MIT Imports: 2 Imported by: 9

Documentation

Overview

Package backoff is a slightly changed version of the backoff algorithm that comes with gRPC See: vendor/google.golang.org/grpc/LICENSE for the license

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultConfig = Config{
		MaxDelay:  120 * time.Second,
		BaseDelay: 1.0 * time.Second,
		Factor:    1.6,
		Jitter:    0.2,
	}
)

DefaultConfig is the default backoff configuration

Functions

func Backoff

func Backoff(retries int) time.Duration

Backoff returns the delay for the current amount of retries

Types

type Config

type Config struct {
	// MaxDelay is the upper bound of backoff delay.
	MaxDelay time.Duration

	// BaseDelay is the amount of time to wait before retrying after the first failure.
	BaseDelay time.Duration

	// factor is applied to the backoff after each retry.
	Factor float64

	// jitter provides a range to randomize backoff delays.
	Jitter float64
}

Config defines the parameters for backoff

func (Config) Backoff

func (bc Config) Backoff(retries int) time.Duration

Backoff returns the delay for the current amount of retries

Jump to

Keyboard shortcuts

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