retry

package
Version: v0.0.0-...-ae2807b Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	InitialBackoff      time.Duration   // Default retry backoff interval
	MaxBackoff          time.Duration   // Maximum retry backoff interval
	Multiplier          float64         // Default backoff constant
	MaxRetries          int             // Maximum number of attempts (0 for infinite)
	RandomizationFactor float64         // Randomize the backoff interval by constant
	Closer              <-chan struct{} // Optionally end retry loop channel close.
}

Options provides reusable configuration of Retry objects.

type Retry

type Retry struct {
	// contains filtered or unexported fields
}

Retry implements the public methods necessary to control an exponential- backoff retry loop.

func Start

func Start(opts Options) Retry

Start returns a new Retry initialized to some default values. The Retry can then be used in an exponential-backoff retry loop.

func (*Retry) CurrentAttempt

func (r *Retry) CurrentAttempt() int

CurrentAttempt it is zero initially and increases with each call to Next() which does not immediately follow a Reset().

func (*Retry) Next

func (r *Retry) Next() bool

Next returns whether the retry loop should continue, and blocks for the appropriate length of time before yielding back to the caller. If a stopper is present, Next will eagerly return false when the stopper is stopped.

func (*Retry) Reset

func (r *Retry) Reset()

Reset resets the Retry to its initial state, meaning that the next call to Next will return true immediately and subsequent calls will behave as if they had followed the very first attempt (i.e. their backoffs will be short).

type Retryable

type Retryable interface {
	CanRetry() bool
}

Retryable is an interface for conditions which may be retried.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL