Categorygithub.com/giantswarm/retry-go
modulepackage
0.0.0-20151203102909-d78cea247d5e
Repository: https://github.com/giantswarm/retry-go.git
Documentation: pkg.go.dev

# README

retry-go

Small helper library to retry operations automatically on certain errors.

Usage

The retry package provides a Do() function which can be used to execute a provided function until it succeds.

op := func() error {
	// Do something that can fail and should be retried here
	return httpClient.CreateUserOnRemoteServer()
}
retry.Do(op, 
         retry.RetryChecker(IsNetOpErr),
         retry.Timeout(15 * time.Second))

Besides the op itself, you can provide a few options:

  • RetryChecker(func(err error) bool) - If this func returns true for the returned error, the operation is tried again (default: nil - no retries)
  • MaxTries(int) - Maximum number of calls to op() before aborting with MaxRetriesReachedErr
  • Timeout(time.Duration) - Maximum number of time to try to perform this op before aborting with TimeoutReachedErr
  • Sleep(time.Duration) - time to sleep after every failed op()

# Functions

AfterRetry is called after a retry and can be used e.g.
AfterRetryLimit is called after a retry limit is reached and can be used e.g.
Do performs the given operation.
IsMaxRetriesReached returns true if the cause of the given error is a MaxRetriesReachedError.
IsTimeout returns true if the cause of the given error is a TimeoutError.
MaxTries specifies the maximum number of times op will be called by Do().
Not is a helper to invert another .
RetryChecker defines whether the given error is an error that can be retried.
No description provided by the author
Timeout specifies the maximum time that should be used before aborting the retry loop.

# Constants

No description provided by the author
No description provided by the author

# Variables

No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author