Documentation ¶
Overview ¶
Package retry contains helper functions that allow you to retry functions on error.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DoWithRetry ¶
func DoWithRetry( logger *logrus.Entry, 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.Entry, 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 ¶
MaxRetriesExceeded is an error that occurs when the maximum amount of retries is exceeded.
func (MaxRetriesExceeded) Error ¶
func (err MaxRetriesExceeded) Error() string