Documentation
¶
Overview ¶
Package apiretry provides retry utilities for Databricks API calls. It composes the generic retry machinery in core/ops with the error classification primitives in core/apierr.
This package is intended for internal use only.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsTransientNetworkError ¶
IsTransientNetworkError reports whether err represents a transient network condition that is likely to resolve on retry.
func NewRetrier ¶
func NewRetrier(bp ops.BackoffPolicy, cfg RetrierConfig) ops.Retrier
NewRetrier returns a ops.Retrier configured by rules. See RetrierConfig for the matching semantics.
Important: the retrier has its own copy of the backoff policy which cannot be trivially reset by design. Users who need to reset the backoff policy should rather create a new retrier.
func RetryDurationHint ¶
RetryDurationHint returns a retry-duration hint extracted from err, if one is available. It examines, in order:
- the Retry-After header on an *apierr.APIError's HTTP response;
- the apierr.RetryInfo detail on an *apierr.APIError.
Returns 0 when err does not carry a hint.
Types ¶
type RetrierConfig ¶
type RetrierConfig struct {
// ErrorCodes are canonical codes considered retriable.
ErrorCodes []codes.Code
// StatusCodes are HTTP status codes considered retriable. Consulted only
// when the error does not carry a canonical code, or when ErrorCodes is
// empty.
StatusCodes []int
}
RetrierConfig describes which errors NewRetrier retries.
Error codes prevail over HTTP statuses. When ErrorCodes is non-empty and the error carries a canonical code that is not codes.Unknown, ErrorCodes is consulted exclusively. Otherwise the HTTP status is examined against StatusCodes.
Transient network errors are always retried regardless of rules. Retry-after hints (either passed in response header or via apierr.RetryInfo) are honored.