Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBackoff ¶
DefaultBackoff provides a default callback for Client.Backoff which will perform exponential backoff based on the attempt number and limited by the provided minimum and maximum durations.
Types ¶
type Backoff ¶
Backoff specifies a policy for how long to wait between retries. It is called after a failing request to determine the amount of time that should pass before trying again.
type CheckForRetry ¶
CheckForRetry specifies a policy for handling retries. It is called following each request with the reponse and error values returned by the http.Client. If it returns false, the Client stops retrying and returns the response to the caller. If it returns an error, that error value is return in lieu of the error from the request.
type Client ¶
type Client struct { HTTPClient *http.Client // Internal HTTP client RetryWaitMin time.Duration // Minimum time to wait RetryWaitMax time.Duration // Maximum time to wait RetryMax int // Maximum number of retries // CheckForRetry specifies the policy for handling retries, and is called // after each request. CheckForRetry CheckForRetry // Backoff specifies the policy for how long to wait between retries Backoff Backoff }
Client is used to make TTP requests. It adds additional functionality like automatic retries to tolerate minor outages.
type Request ¶
type Request struct { // Embed an HTTP request directly. This makes a *Request act exacty // like an *http.Request so that all meta methods are supported. *http.Request // contains filtered or unexported fields }
Request wraps the metadata needed to create HTTP requests
func NewRequestWithContext ¶
func NewRequestWithContext(ctx context.Context, method, url string, body io.ReadSeeker) (*Request, error)
NewRequestWithContext creates a new wrapped request