1d54909333
This only affects vault versions >=1.1.1 because the prior code accidentally relied upon a bug that was fixed in https://github.com/hashicorp/vault/pull/6505 The existing tests should have caught this, but they were using a vendored copy of vault version 0.10.3. This fixes the tests by running an actual copy of vault instead of an in-process copy. This has the added benefit of changing the dependency on vault to just vault/api. Also update VaultProvider to use similar SetIntermediate validation code as the ConsulProvider implementation. |
||
---|---|---|
.. | ||
.gitignore | ||
.travis.yml | ||
LICENSE | ||
Makefile | ||
README.md | ||
client.go | ||
go.mod | ||
go.sum |
README.md
go-retryablehttp
The retryablehttp
package provides a familiar HTTP client interface with
automatic retries and exponential backoff. It is a thin wrapper over the
standard net/http
client library and exposes nearly the same public API. This
makes retryablehttp
very easy to drop into existing programs.
retryablehttp
performs automatic retries under certain conditions. Mainly, if
an error is returned by the client (connection errors, etc.), or if a 500-range
response code is received (except 501), then a retry is invoked after a wait
period. Otherwise, the response is returned and left to the caller to
interpret.
The main difference from net/http
is that requests which take a request body
(POST/PUT et. al) can have the body provided in a number of ways (some more or
less efficient) that allow "rewinding" the request body if the initial request
fails so that the full request can be attempted again. See the
godoc for more
details.
Example Use
Using this library should look almost identical to what you would do with
net/http
. The most simple example of a GET request is shown below:
resp, err := retryablehttp.Get("/foo")
if err != nil {
panic(err)
}
The returned response object is an *http.Response
, the same thing you would
usually get from net/http
. Had the request failed one or more times, the above
call would block and retry with exponential backoff.
For more usage and examples see the godoc.