Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithRetries ¶
func WithRetries(ctx *log.Context, rm *RequestManager, sf SleepFunc, eTag string) (*http.Response, error)
WithRetries retrieves a response body using the specified downloader. Any error returned from d will be retried (and retrieved response bodies will be closed on failures). If the retries do not succeed, the last error is returned.
It sleeps in exponentially increasing durations between retries.
Types ¶
type RequestFactory ¶
type RequestFactory interface { // GetRequest returns a new GET request for the resource. GetRequest(ctx *log.Context, eTag string) (*http.Request, error) }
RequestFactory describes a method to create HTTP requests.
type RequestManager ¶
type RequestManager struct {
// contains filtered or unexported fields
}
RequestManager provides an abstraction for http requests
func GetRequestManager ¶
func GetRequestManager(rf RequestFactory, timeout time.Duration) *RequestManager
GetRequestManager returns a request manager for json requests
func (*RequestManager) MakeRequest ¶
MakeRequest retrieves a response body and checks the response status code to see if it is 200 OK and then returns the response body. It issues a new request every time called. It is caller's responsibility to close the response body.