Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsPermanentError ¶ added in v0.17.0
IsPermanentError returns true if an error value is or contains a PermanentError in its chain of errors.
func IsTemporaryError ¶ added in v0.17.0
IsTemporaryError returns true if an error value is or contains a TemporaryError in its chain of errors.
func Permanent ¶ added in v0.17.0
Permanent creates a PermanentError that signals to a retry loop that it should stop retrying an operation and return the underlying error.
func Temporary ¶ added in v0.17.0
Temporary creates a TemporaryError that signals to a retry loop that an operation can be retried. The error may also carry details about how long to wait before retrying. This wait interval may be used to override the retry policy in use.
func TemporaryFromResponse ¶ added in v0.17.0
TemporaryFromResponse creates a TemporaryError similar to Temporary but additionally parses the Retry-After header from a response to determine the wait interval before the next retry attempt.
Types ¶
type BackoffStrategy ¶
type BackoffStrategy struct {
InitialInterval int
MaxInterval int
Exponent float64
MaxElapsedTime int
}
BackoffStrategy defines the parameters for exponential backoff. This can be used to drive a retry loop for example.
type Config ¶
type Config struct {
// Strategy sets the algorithm to use for a retry loop. It can be one of:
// - "backoff": retry with exponential backoff and random jitter.
// - "none" or "": disables retries.
Strategy string
Backoff *BackoffStrategy
RetryConnectionErrors bool
}
Config configures a retry policy.
type PermanentError ¶ added in v0.17.0
type PermanentError struct {
// contains filtered or unexported fields
}
PermanentError is an error that signals that some operation has terminally failed and should not be retried.
func (*PermanentError) Error ¶ added in v0.17.0
func (e *PermanentError) Error() string
func (*PermanentError) Unwrap ¶ added in v0.17.0
func (e *PermanentError) Unwrap() error
type TemporaryError ¶ added in v0.17.0
type TemporaryError struct {
// contains filtered or unexported fields
}
TemporaryError represents a retryable error and signals to a retry loop that an operation may be retried with an optional wait interval.
func (*TemporaryError) Error ¶ added in v0.17.0
func (e *TemporaryError) Error() string
func (*TemporaryError) RetryAfter ¶ added in v0.17.0
func (e *TemporaryError) RetryAfter() time.Duration
RetryAfter returns the time to wait before retrying the request. The zero value should be interpreted by retry loops to mean they should fallback on their default policy whether expenonential, constant backoff or something else. It does not mean that an operation should be retried immediately.