Documentation
¶
Index ¶
- func CloneHeader(headers http.Header) http.Header
- func CloneValues(values url.Values) url.Values
- func CloseResponse(resp *http.Response)
- func DecodeJSON(resp *http.Response, body []byte, provider string, out any) error
- func EnsureLeadingSlash(path string) string
- func Execute(ctx context.Context, client *http.Client, retry RetryPolicy, ...) (*http.Response, []byte, error)
- func JoinPath(parts ...string) string
- func ParseRetryAfter(value string, now time.Time) (time.Duration, bool)
- func SleepWithContext(ctx context.Context, d time.Duration) error
- func SnapshotBody(resp *http.Response) ([]byte, error)
- type RetryClassifier
- type RetryDecision
- type RetryPolicy
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseResponse ¶
func EnsureLeadingSlash ¶
Types ¶
type RetryClassifier ¶
type RetryClassifier func(policy RetryPolicy, resp *http.Response, err error, attempt int) RetryDecision
type RetryDecision ¶
func DefaultRetryClassifier ¶
func DefaultRetryClassifier(policy RetryPolicy, resp *http.Response, err error, attempt int) RetryDecision
type RetryPolicy ¶
type RetryPolicy struct {
MaxAttempts int
BaseDelay time.Duration
MaxDelay time.Duration
Sleep func(context.Context, time.Duration) error
Rand func() float64
Clock func() time.Time
Classifier RetryClassifier
}
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() RetryPolicy
func (RetryPolicy) ExponentialBackoff ¶
func (p RetryPolicy) ExponentialBackoff(attempt int) time.Duration
func (RetryPolicy) JitterBackoff ¶
func (p RetryPolicy) JitterBackoff(attempt int) time.Duration
func (RetryPolicy) Now ¶
func (p RetryPolicy) Now() time.Time
Click to show internal directories.
Click to hide internal directories.