Documentation ¶
Index ¶
- func DefaultBackoff(_ uint, c *Config) time.Duration
- func Do(ctx context.Context, logger *zap.Logger, scope tally.Scope, fn RetryableFunc, ...) error
- func ExponentialBackoff(i uint, _ *Config) time.Duration
- func JitterBackoff(_ uint, c *Config) time.Duration
- type BackoffStrategy
- type Config
- type MultiError
- type Option
- type RetryableFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBackoff ¶
DefaultBackoff always returns a fixed delay duration.
func Do ¶
func Do(ctx context.Context, logger *zap.Logger, scope tally.Scope, fn RetryableFunc, opts ...Option) error
Do retries a given function with delays between each attempts as defined by the caller or their corresponding defaults.
err := retry.Do( ctx, logger, scope, func() error { return nil }, Backoff(ExponentialBackoff), )
func ExponentialBackoff ¶
ExponentialBackoff returns exponentially increasing backoffs by a power of 2.
Types ¶
type BackoffStrategy ¶
BackoffStrategy is used to determine the delay between retries.
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config defines the behavior of retries.
type MultiError ¶
type MultiError []error
MultiError is a slice of errors ocurred while retrying.
func (MultiError) Error ¶
func (m MultiError) Error() string
Error implements the error interface.
Returns all the errors occurred during retry formatted as a string separated by newlines.
type Option ¶
type Option func(*Config)
Option is an option for retry.
func Backoff ¶
func Backoff(backoff BackoffStrategy) Option
Backoff sets the backoff mechanism used while retrying.
type RetryableFunc ¶
type RetryableFunc func() error
RetryableFunc represents a function that is retryable.