retry

package
v3.18.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 20, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPermanentError added in v3.15.8

func IsPermanentError(err error) bool

IsPermanentError returns true if an error value is or contains a PermanentError in its chain of errors.

func IsTemporaryError added in v3.15.8

func IsTemporaryError(err error) bool

IsTemporaryError returns true if an error value is or contains a TemporaryError in its chain of errors.

func Permanent added in v3.15.8

func Permanent(cause error) error

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 v3.15.8

func Temporary(message string) error

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 v3.15.8

func TemporaryFromResponse(message string, res *http.Response) error

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              string
	Backoff               *BackoffStrategy
	RetryConnectionErrors bool
}

Config configures a retry policy.

type PermanentError added in v3.15.8

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 v3.15.8

func (e *PermanentError) Error() string

func (*PermanentError) Unwrap added in v3.15.8

func (e *PermanentError) Unwrap() error

type TemporaryError added in v3.15.8

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 v3.15.8

func (e *TemporaryError) Error() string

func (*TemporaryError) RetryAfter added in v3.15.8

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL