retryhandler

package
v0.35.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 12 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxRetryAfter = 30 * time.Second

MaxRetryAfter is the longest server-requested delay accepted for a retry. It is independent of the exponential backoff budget. Code which embeds BuildKit can override the default value.

View Source
var MaxRetryBackoff = 8 * time.Second

MaxRetryBackoff is the maximum backoff time before giving up. This is a variable so that code which embeds BuildKit can override the default value.

Functions

func New

func New(f images.HandlerFunc, logger func([]byte)) images.HandlerFunc

func WithRetry added in v0.34.0

func WithRetry[T any](ctx context.Context, logger func([]byte), f func(context.Context) (T, error)) (T, error)

WithRetry retries transient failures with jittered exponential backoff. Nested calls using the supplied context leave retries to the outer call, including New. f must be safe to retry and preserve retryable errors when wrapping them.

func WithRetryIf added in v0.34.0

func WithRetryIf[T any](ctx context.Context, logger func([]byte), f func(context.Context) (T, error), shouldRetry func(error) bool) (T, error)

WithRetryIf applies the normal retry policy only when shouldRetry also accepts the error. A nil predicate accepts all errors in the normal policy. This lets callers avoid retrying errors handled by an enclosing transport.

Types

type RetryAfterError added in v0.35.0

type RetryAfterError struct {
	Err   error
	Delay time.Duration
}

RetryAfterError marks a failure as retryable after at least Delay. A zero Delay uses the normal backoff. Delays above MaxRetryAfter stop retries rather than retrying before the requested delay has elapsed.

func (*RetryAfterError) Error added in v0.35.0

func (e *RetryAfterError) Error() string

func (*RetryAfterError) Unwrap added in v0.35.0

func (e *RetryAfterError) Unwrap() error

Jump to

Keyboard shortcuts

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