Documentation
¶
Overview ¶
Package retry provides a generic retry mechanism with exponential backoff. It is designed for operations that may fail transiently, such as gRPC calls or network requests, where retrying after a short delay can succeed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Do ¶
Do executes fn, retrying on errors that IsRetryable returns true for. It uses exponential backoff between retries and respects context cancellation.
func GRPCTransient ¶
GRPCTransient returns true for gRPC errors that indicate a transient failure: Unavailable and DeadlineExceeded.
Types ¶
type Config ¶
type Config struct {
// MaxAttempts is the total number of attempts including the initial call.
MaxAttempts int
// BaseBackoff is the initial backoff duration. Each subsequent retry doubles it.
BaseBackoff time.Duration
// IsRetryable determines whether an error should be retried.
IsRetryable func(error) bool
}
Config holds the retry parameters.
Click to show internal directories.
Click to hide internal directories.