Documentation
¶
Index ¶
- Variables
- func New(f images.HandlerFunc, logger func([]byte)) images.HandlerFunc
- func WithRetry[T any](ctx context.Context, logger func([]byte), f func(context.Context) (T, error)) (T, error)
- func WithRetryIf[T any](ctx context.Context, logger func([]byte), f func(context.Context) (T, error), ...) (T, error)
- type RetryAfterError
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
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 ¶
func (e *RetryAfterError) Error() string
func (*RetryAfterError) Unwrap ¶
func (e *RetryAfterError) Unwrap() error