retry

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2018 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(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(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