retry

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: MIT Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoWithRetry

func DoWithRetry(
	logger *logrus.Logger,
	actionDescription string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
	action func() error,
) error

DoWithRetry runs the specified action. If it returns a FatalError, return that error immediately. If it returns any other type of error, sleep for sleepBetweenRetries and try again, up to a maximum of maxRetries retries. If maxRetries is exceeded, return a MaxRetriesExceeded error.

func DoWithRetryInterface

func DoWithRetryInterface(
	logger *logrus.Logger,
	actionDescription string,
	maxRetries int,
	sleepBetweenRetries time.Duration,
	action func() (interface{}, error),
) (interface{}, error)

DoWithRetryInterface runs the specified action. If it returns a value, return that value. If it returns a FatalError, return that error immediately. If it returns any other type of error, sleep for sleepBetweenRetries and try again, up to a maximum of maxRetries retries. If maxRetries is exceeded, return a MaxRetriesExceeded error.

Types

type FatalError

type FatalError struct {
	Underlying error
}

FatalError is a marker interface for errors that should not be retried.

func (FatalError) Error

func (err FatalError) Error() string

type MaxRetriesExceeded

type MaxRetriesExceeded struct {
	Description string
	MaxRetries  int
}

MaxRetriesExceeded is an error that occurs when the maximum amount of retries is exceeded.

func (MaxRetriesExceeded) Error

func (err MaxRetriesExceeded) Error() string

Jump to

Keyboard shortcuts

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