packer-cn/vendor/github.com/hashicorp/go-retryablehttp
Adrien Delorme 4ebcbad332
update consul and vault dependencies (#9205)
* update consul and vault dependencies

* update triton sign call accorting to https://github.com/joyent/triton-go/pull/135

* Delete readme.md

* put back github.com/mitchellh/reflectwalk to v1.0.0 and explain why

* fix/fixer_pp_docker_tag_tags.go: simplify deduplication loop and keep seen/stable order
2020-05-11 15:26:01 -04:00
..
.gitignore update consul and vault dependencies (#9205) 2020-05-11 15:26:01 -04:00
.travis.yml update consul and vault dependencies (#9205) 2020-05-11 15:26:01 -04:00
LICENSE deps: Add joyent/triton-go 2017-04-26 14:02:04 -07:00
Makefile deps: Add joyent/triton-go 2017-04-26 14:02:04 -07:00
README.md add template function allowing user to read keys from vault 2018-08-28 11:23:47 -07:00
client.go update consul and vault dependencies (#9205) 2020-05-11 15:26:01 -04:00
go.mod go mod vendor && go mod tidy 2019-04-11 14:19:24 +02:00
go.sum go mod vendor && go mod tidy 2019-04-11 14:19:24 +02:00

README.md

go-retryablehttp

Build Status Go Documentation

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.