retry

package
v1.5.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2019 License: Apache-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(ctx context.Context, operation func() error, retryOnError func(err error) bool) error

Do retries the given function until defaultMaxInterval time passes, while sleeping some time between unsuccessful attempts if retryOnError returns true, continue retry, otherwise, return error

func DoWithConfig

func DoWithConfig(ctx context.Context, operation func() error, retryOnError func(err error) bool, config *BackoffConfig) error

DoWithConfig will attempt an operation while retrying using an exponential back off based on the config supplied by the caller. The retry decider is the supplied function retryOnError

func OnError

func OnError(err error) bool

OnError is the simplest of retry deciders. If an error occurs it will indicate a retry is needed.

Types

type BackoffConfig

type BackoffConfig struct {
	InitialInterval     time.Duration
	RandomizationFactor float64
	Multiplier          float64
	MaxInterval         time.Duration

	// this field will indicate the maximum amount of "sleep" time that will occur.
	MaxElapsedTime time.Duration
}

simplified config for configuring a back off object. Callers should populate and supply this to DoWithConfig

func NewBackoffConfig

func NewBackoffConfig() *BackoffConfig

Generate a new BackoffConfig with default values

Jump to

Keyboard shortcuts

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