Documentation ¶
Index ¶
Constants ¶
const DefaultMaxRetry uint64 = 10
DefaultMaxRetry is default max retry times
Variables ¶
This section is empty.
Functions ¶
func DefaultRetryFunc ¶
DefaultRetryFunc retry when the response status code is in range of 500 but not 501 which is http.StatusNotImplemented
Types ¶
type BackOff ¶
BackOff is a backoff policy for retrying an operation.
func DefaultBackOff ¶
func DefaultBackOff() BackOff
DefaultBackOff return a backoff policy with exponential backoff wrapped with a 10-times-max-retry.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a http retry client
func NewWithClient ¶
NewWithClient return a new retry client which use the given http.Client
func (*Client) DoWithBackOff ¶
DoWithBackOff execute the given request with the given backoff policy. It uses the DefaultRetryFunc which will retry if response status code is in range of 500 but not http.StatusNotImplemented.
func (*Client) DoWithRetryFunc ¶
DoWithRetryFunc execute the given request with the given backoff policy. A retry is determined by the given retry Func.
func (*Client) WithLogger ¶
WithLogger ask the client to usse the given logger instead of default logger (logrus)