Documentation
¶
Index ¶
- Constants
- Variables
- func HeaderMap(h http.Header) map[string]string
- func IsHTTPStatusRetryable(httpStatusCode int) (ok bool)
- func IsHTTPSuccessStatus(httpStatusCode int) (ok bool)
- func NewRetryTimer(ctx context.Context, opts ...func(option *RetryOption)) <-chan int
- func ParseProxy(proxy string) (*url.URL, error)
- func Transport(secure bool, proxy func(*http.Request) (*url.URL, error)) *http.Transport
- type DefaultRequest
- type Request
- type RequestOption
- type ResponseParse
- type Retry
- type RetryOption
Constants ¶
View Source
const ( MaxJitter = 1.0 NoJitter = 0.0 )
Variables ¶
View Source
var ( MaxRetry = 3 RetryUnit = 100 * time.Millisecond RetryCap = time.Second Random = rand.New(rand.NewSource(time.Now().UTC().UnixNano())) )
View Source
var (
DefaultRespParse = &defaultParse{}
)
View Source
var RetryableHTTPStatusCodes = map[int]struct{}{ http.StatusTooManyRequests: {}, http.StatusInternalServerError: {}, http.StatusBadGateway: {}, http.StatusServiceUnavailable: {}, http.StatusGatewayTimeout: {}, }
View Source
var SuccessStatusCodes = map[int]struct{}{ http.StatusOK: {}, http.StatusNoContent: {}, http.StatusPartialContent: {}, }
Functions ¶
func IsHTTPStatusRetryable ¶
func IsHTTPSuccessStatus ¶
func NewRetryTimer ¶
func NewRetryTimer(ctx context.Context, opts ...func(option *RetryOption)) <-chan int
Types ¶
type Request ¶
type Request interface { Do(*http.Request) (*http.Response, error) ContextDo(context.Context, *http.Request) (*http.Response, error) }
func NewRequest ¶
func NewRequest(opts ...RequestOption) Request
type RequestOption ¶
type RequestOption func(r *DefaultRequest)
type ResponseParse ¶
type Retry ¶
type Retry func(option *RetryOption)
func WithJitter ¶
func WithMaxRetry ¶
func WithRandom ¶
func WithRetryCap ¶
func WithRetryUnit ¶
type RetryOption ¶
type RetryOption struct {
// contains filtered or unexported fields
}
Click to show internal directories.
Click to hide internal directories.