Update go-retryablehttp and affected deps

This commit is contained in:
Jeff Mitchell 2018-07-19 08:50:18 -04:00
parent 498a8d9456
commit bb057dd1df
7 changed files with 51 additions and 19 deletions

View File

@ -1,3 +1,8 @@
# v2.1.2
* upd: breaking change in upstream repo
* upd: upstream deps
# v2.1.1
* dep dependencies

View File

@ -5,7 +5,7 @@
branch = "master"
name = "github.com/circonus-labs/circonusllhist"
packages = ["."]
revision = "1e65893c445875524c5610f2a58aef24e30ef98a"
revision = "5eb751da55c6d3091faf3861ec5062ae91fee9d0"
[[projects]]
branch = "master"
@ -17,7 +17,7 @@
branch = "master"
name = "github.com/hashicorp/go-retryablehttp"
packages = ["."]
revision = "794af36148bf63c118d6db80eb902a136b907e71"
revision = "e651d75abec6fbd4f2c09508f72ae7af8a8b7171"
[[projects]]
name = "github.com/pkg/errors"

View File

@ -97,7 +97,7 @@ func main() {
## Notes:
* All options are *strings* with the following exceptions:
* `cfg.Log` - an instance of [`log.Logger`](https://golang.org/pkg/log/#Logger) or something else (e.g. [logrus](https://github.com/sirupsen/logrus)) which can be used to satisfy the interface requirements.
* `cfg.Log` - an instance of [`log.Logger`](https://golang.org/pkg/log/#Logger) or something else (e.g. [logrus](https://github.com/Sirupsen/logrus)) which can be used to satisfy the interface requirements.
* `cfg.Debug` - a boolean true|false.
* At a minimum, one of either `API.TokenKey` or `Check.SubmissionURL` is **required** for cgm to function.
* Check management can be disabled by providing a `Check.SubmissionURL` without an `API.TokenKey`. Note: the supplied URL needs to be http or the broker needs to be running with a cert which can be verified. Otherwise, the `API.TokenKey` will be required to retrieve the correct CA certificate to validate the broker's cert for the SSL connection.

View File

@ -6,6 +6,7 @@ package api
import (
"bytes"
"context"
crand "crypto/rand"
"crypto/tls"
"crypto/x509"
@ -279,7 +280,11 @@ func (a *API) apiCall(reqMethod string, reqPath string, data []byte) ([]byte, er
// keep last HTTP error in the event of retry failure
var lastHTTPError error
retryPolicy := func(resp *http.Response, err error) (bool, error) {
retryPolicy := func(ctx context.Context, resp *http.Response, err error) (bool, error) {
if ctxErr := ctx.Err(); ctxErr != nil {
return false, ctxErr
}
if err != nil {
lastHTTPError = err
return true, err

View File

@ -6,6 +6,7 @@ package circonusgometrics
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -71,7 +72,11 @@ func (m *CirconusMetrics) trapCall(payload []byte) (int, error) {
// keep last HTTP error in the event of retry failure
var lastHTTPError error
retryPolicy := func(resp *http.Response, err error) (bool, error) {
retryPolicy := func(ctx context.Context, resp *http.Response, err error) (bool, error) {
if ctxErr := ctx.Err(); ctxErr != nil {
return false, ctxErr
}
if err != nil {
lastHTTPError = err
return true, errors.Wrap(err, "retry policy")

View File

@ -23,6 +23,7 @@ package retryablehttp
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
@ -73,6 +74,13 @@ type Request struct {
*http.Request
}
// WithContext returns wrapped Request with a shallow copy of underlying *http.Request
// with its context changed to ctx. The provided ctx must be non-nil.
func (r *Request) WithContext(ctx context.Context) *Request {
r.Request = r.Request.WithContext(ctx)
return r
}
// NewRequest creates a new wrapped request.
func NewRequest(method, url string, rawBody interface{}) (*Request, error) {
var err error
@ -196,7 +204,7 @@ type ResponseLogHook func(*log.Logger, *http.Response)
// Client will close any response body when retrying, but if the retry is
// aborted it is up to the CheckResponse callback to properly close any
// response body before returning.
type CheckRetry func(resp *http.Response, err error) (bool, error)
type CheckRetry func(ctx context.Context, resp *http.Response, err error) (bool, error)
// Backoff specifies a policy for how long to wait between retries.
// It is called after a failing request to determine the amount of time
@ -253,7 +261,12 @@ func NewClient() *Client {
// DefaultRetryPolicy provides a default callback for Client.CheckRetry, which
// will retry on connection errors and server errors.
func DefaultRetryPolicy(resp *http.Response, err error) (bool, error) {
func DefaultRetryPolicy(ctx context.Context, resp *http.Response, err error) (bool, error) {
// do not retry on context.Canceled or context.DeadlineExceeded
if ctx.Err() != nil {
return false, ctx.Err()
}
if err != nil {
return true, err
}
@ -361,7 +374,7 @@ func (c *Client) Do(req *Request) (*http.Response, error) {
}
// Check if we should continue with retries.
checkOK, checkErr := c.CheckRetry(resp, err)
checkOK, checkErr := c.CheckRetry(req.Request.Context(), resp, err)
if err != nil {
if c.Logger != nil {

26
vendor/vendor.json vendored
View File

@ -595,22 +595,26 @@
"revisionTime": "2018-05-24T23:10:29Z"
},
{
"checksumSHA1": "l8gIVOjlnOrceuJLONvgA8p4FI4=",
"checksumSHA1": "XZGYFHhCogxNxPW12m2isdjzHV8=",
"path": "github.com/circonus-labs/circonus-gometrics",
"revision": "b5b9c6e8f93c67411193a170108e951e642c453c",
"revisionTime": "2018-02-07T19:24:15Z"
"revision": "f57cec857aa60ee9ffa19016d5edc822f9b1fea1",
"revisionTime": "2018-07-19T04:14:26Z"
},
{
"checksumSHA1": "I6MmriS6eBxiKW9g+p23t0YFDVg=",
"checksumSHA1": "z3WEOjH/vGFhybYzw8jrug2EE6s=",
"path": "github.com/circonus-labs/circonus-gometrics/api",
"revision": "b5b9c6e8f93c67411193a170108e951e642c453c",
"revisionTime": "2018-02-07T19:24:15Z"
"revision": "f57cec857aa60ee9ffa19016d5edc822f9b1fea1",
"revisionTime": "2018-07-19T04:14:26Z"
},
{
"path": "github.com/circonus-labs/circonus-gometrics/api/checkmgr",
"revision": ""
},
{
"checksumSHA1": "bQhz/fcyZPmuHSH2qwC4ZtATy5c=",
"path": "github.com/circonus-labs/circonus-gometrics/api/config",
"revision": "b5b9c6e8f93c67411193a170108e951e642c453c",
"revisionTime": "2018-02-07T19:24:15Z"
"revision": "f57cec857aa60ee9ffa19016d5edc822f9b1fea1",
"revisionTime": "2018-07-19T04:14:26Z"
},
{
"checksumSHA1": "YCRBAIvGNWV9L59Wu7GjUVwpK7Q=",
@ -1113,10 +1117,10 @@
"revisionTime": "2018-03-31T00:25:53Z"
},
{
"checksumSHA1": "s6mKR1dSKP04+A3kwSsFr/PvsOU=",
"checksumSHA1": "/yKfFSspjuDzyOe/bBslrPzyfYM=",
"path": "github.com/hashicorp/go-retryablehttp",
"revision": "3b087ef2d313afe6c55b2f511d20db04ca767075",
"revisionTime": "2018-05-31T21:13:21Z"
"revision": "e651d75abec6fbd4f2c09508f72ae7af8a8b7171",
"revisionTime": "2018-07-18T19:50:05Z"
},
{
"checksumSHA1": "A1PcINvF3UiwHRKn8UcgARgvGRs=",