Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ExponentialBackoff ¶
type ExponentialBackoff struct {
BaseDelay time.Duration
MaxDelay time.Duration
Retries int
AttemptTimeout time.Duration
// Jitter factor (0.0 to 1.0)
Jitter float64
}
ExponentialBackoff implements a standard exponential backoff with jitter.
func (*ExponentialBackoff) Backoff ¶
func (b *ExponentialBackoff) Backoff(attempt int) time.Duration
func (*ExponentialBackoff) IsRetryable ¶
func (b *ExponentialBackoff) IsRetryable(err error) bool
func (*ExponentialBackoff) MaxRetries ¶
func (b *ExponentialBackoff) MaxRetries() int
func (*ExponentialBackoff) Timeout ¶
func (b *ExponentialBackoff) Timeout() time.Duration
type RetryPolicy ¶
type RetryPolicy interface {
// Backoff returns the duration to wait before the next attempt.
// attempt is 0-indexed.
Backoff(attempt int) time.Duration
// MaxRetries returns the maximum number of retry attempts.
MaxRetries() int
// Timeout returns the timeout for a single attempt.
Timeout() time.Duration
// IsRetryable returns true if the error should be retried.
IsRetryable(err error) bool
}
RetryPolicy defines the interface for backoff strategies.
Click to show internal directories.
Click to hide internal directories.