-
Notifications
You must be signed in to change notification settings - Fork 2
/
config.go
42 lines (32 loc) · 907 Bytes
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Copyright 2022 Edgecast Inc., Licensed under the terms of the Apache 2.0
// license. See LICENSE file in project root for terms.
package ecretryablehttp
import (
"context"
"net/http"
"time"
"github.com/EdgeCast/ec-sdk-go/edgecast/eclog"
)
const (
DefaultRetryWaitMinSeconds = 1
DefaultRetryWaitMaxSeconds = 60
DefaultRetryMax = 5
)
type RetryConfig struct {
// Logger -
Logger eclog.Logger
// The minimum wait time for retries on API errors
RetryWaitMin *time.Duration
// The maximum wait time for retries on API errors
RetryWaitMax *time.Duration
// The maximum number of retries on API errors
RetryMax *int
// CheckRetry is a handler that allows users to define custom logic
// to determine whether the API Client should retry a failed API call
CheckRetry CheckRetry
}
type CheckRetry func(
ctx context.Context,
resp *http.Response,
err error,
) (bool, error)