clients

package
v0.0.0-...-d9a1f69 Latest Latest
Warning

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

Go to latest
Published: May 21, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Deprecated package providing utilities for defining HTTP clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckRetry

func CheckRetry(ctx context.Context, resp *http.Response, err error) (bool, error)

func DefaultRetryPolicy

func DefaultRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)

func DurationToSeconds

func DurationToSeconds(duration time.Duration) float64

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

func SecondsToDuration(seconds float64) time.Duration

func UpsertBucketRetryPolicy

func UpsertBucketRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error)

Types

type ContextKey

type ContextKey string
const CtxRetryPolicyKey ContextKey = "retryFunc"

Jump to

Keyboard shortcuts

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