diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index 76b79ce9a..bd4461aa2 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -718,7 +718,7 @@ }, { "ImportPath": "github.com/hashicorp/go-retryablehttp", - "Rev": "24fda80b7c713c52649e57ce20100d453f7bdb24" + "Rev": "5ec125ef739293cb4d57c3456dd92ba9af29ed6e" }, { "ImportPath": "github.com/hashicorp/go-rootcerts", diff --git a/vendor/github.com/hashicorp/go-retryablehttp/.gitignore b/vendor/github.com/hashicorp/go-retryablehttp/.gitignore new file mode 100644 index 000000000..caab963a3 --- /dev/null +++ b/vendor/github.com/hashicorp/go-retryablehttp/.gitignore @@ -0,0 +1,3 @@ +.idea/ +*.iml +*.test diff --git a/vendor/github.com/hashicorp/go-retryablehttp/client.go b/vendor/github.com/hashicorp/go-retryablehttp/client.go index 64876a6c8..db9eada8a 100644 --- a/vendor/github.com/hashicorp/go-retryablehttp/client.go +++ b/vendor/github.com/hashicorp/go-retryablehttp/client.go @@ -80,6 +80,12 @@ func NewRequest(method, url string, body io.ReadSeeker) (*Request, error) { return &Request{body, httpReq}, nil } +// RequestLogHook allows a function to run before each retry. The HTTP +// request which will be made, and the retry number (0 for the initial +// request) are available to users. The internal logger is exposed to +// consumers. +type RequestLogHook func(*log.Logger, *http.Request, int) + // Client is used to make HTTP requests. It adds additional functionality // like automatic retries to tolerate minor outages. type Client struct { @@ -89,6 +95,10 @@ type Client struct { RetryWaitMin time.Duration // Minimum time to wait RetryWaitMax time.Duration // Maximum time to wait RetryMax int // Maximum number of retries + + // RequestLogHook allows a user-supplied function to be called + // before each retry. + RequestLogHook RequestLogHook } // NewClient creates a new Client with default settings. @@ -116,6 +126,10 @@ func (c *Client) Do(req *Request) (*http.Response, error) { } } + if c.RequestLogHook != nil { + c.RequestLogHook(c.Logger, req.Request, i) + } + // Attempt the request resp, err := c.HTTPClient.Do(req.Request) if err != nil {