Documentation ¶
Overview ¶
Deprecated package providing utilities for defining HTTP clients.
Index ¶
- func CheckRetry(ctx context.Context, resp *http.Response, err error) (bool, error)
- func DefaultRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)
- func DurationToSeconds(duration time.Duration) float64
- func ExponentialBackoffWithJitter(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration
- func SecondsToDuration(seconds float64) time.Duration
- func UpsertBucketRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)
- type ContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRetry ¶
func DefaultRetryPolicy ¶
func DurationToSeconds ¶
func ExponentialBackoffWithJitter ¶
func ExponentialBackoffWithJitter(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration
ExponentialBackoffWithJitter returns a duration to sleep for based on the attempt number, the minimum and maximum durations, and the response. If the response is nil or not a 429, the response is ignored. If the response is a 429, the Retry-After header is used to determine the duration to sleep for. Otherwise, the sleep duration is calculated as:
min * 2^(attemptNum)
If the calculated duration is greater than max, max is used instead. A random jitter is added to the calculated duration, unless the calculated duration is >= max. The jitter is at most 25% of the calculated duration.
func SecondsToDuration ¶
Types ¶
Click to show internal directories.
Click to hide internal directories.