Update go-retryablehttp to get bodybytes, and circonus deps as those break without it

This commit is contained in:
Jeff Mitchell 2019-02-01 17:13:21 -05:00
parent 2f9a7c6203
commit 17755b8150
8 changed files with 81 additions and 52 deletions

View file

@ -1,3 +1,12 @@
# v2.2.6
* fix: func signature to match go-retryablehttp update
* upd: dependency go-retryablehttp, lock to v0.5.2 to prevent future breaking patch features
# v2.2.5
* upd: switch from tracking master to versions for retryablehttp and circonusllhist now that both repositories are doing releases
# v2.2.4 # v2.2.4
* fix: worksheet.graphs is a required attribute. worksheet.smart_queries is an optional attribute. * fix: worksheet.graphs is a required attribute. worksheet.smart_queries is an optional attribute.

View file

@ -2,28 +2,28 @@
[[projects]] [[projects]]
branch = "master"
name = "github.com/circonus-labs/circonusllhist" name = "github.com/circonus-labs/circonusllhist"
packages = ["."] packages = ["."]
revision = "5eb751da55c6d3091faf3861ec5062ae91fee9d0" revision = "87d4d00b35adeefe4911ece727838749e0fab113"
version = "v0.1.3"
[[projects]] [[projects]]
branch = "master"
name = "github.com/hashicorp/go-cleanhttp" name = "github.com/hashicorp/go-cleanhttp"
packages = ["."] packages = ["."]
revision = "d5fe4b57a186c716b0e00b8c301cbd9b4182694d" revision = "e8ab9daed8d1ddd2d3c4efba338fe2eeae2e4f18"
version = "v0.5.0"
[[projects]] [[projects]]
branch = "master"
name = "github.com/hashicorp/go-retryablehttp" name = "github.com/hashicorp/go-retryablehttp"
packages = ["."] packages = ["."]
revision = "e651d75abec6fbd4f2c09508f72ae7af8a8b7171" revision = "73489d0a1476f0c9e6fb03f9c39241523a496dfd"
version = "v0.5.2"
[[projects]] [[projects]]
name = "github.com/pkg/errors" name = "github.com/pkg/errors"
packages = ["."] packages = ["."]
revision = "645ef00459ed84a119197bfb8d8205042c6df63d" revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4"
version = "v0.8.0" version = "v0.8.1"
[[projects]] [[projects]]
branch = "master" branch = "master"
@ -34,6 +34,6 @@
[solve-meta] [solve-meta]
analyzer-name = "dep" analyzer-name = "dep"
analyzer-version = 1 analyzer-version = 1
inputs-digest = "6db34ba31cd011426f28b5db0dbe259c4dc3787fb2074b2c06cb382385a90242" inputs-digest = "ff81639f2f1513555846304ee903af4d13a0f0f181e140e1ebb1d71aa18fb5fb"
solver-name = "gps-cdcl" solver-name = "gps-cdcl"
solver-version = 1 solver-version = 1

View file

@ -1,36 +1,14 @@
# Gopkg.toml example
#
# Refer to https://github.com/golang/dep/blob/master/docs/Gopkg.toml.md
# for detailed Gopkg.toml documentation.
#
# required = ["github.com/user/thing/cmd/thing"]
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
#
# [[constraint]]
# name = "github.com/user/project"
# version = "1.0.0"
#
# [[constraint]]
# name = "github.com/user/project2"
# branch = "dev"
# source = "github.com/myfork/project2"
#
# [[override]]
# name = "github.com/x/y"
# version = "2.4.0"
[[constraint]] [[constraint]]
branch = "master"
name = "github.com/circonus-labs/circonusllhist" name = "github.com/circonus-labs/circonusllhist"
version = "0.1.3"
[[constraint]] [[constraint]]
branch = "master"
name = "github.com/hashicorp/go-retryablehttp" name = "github.com/hashicorp/go-retryablehttp"
version = "=0.5.2"
[[constraint]] [[constraint]]
name = "github.com/pkg/errors" name = "github.com/pkg/errors"
version = "0.8.0" version = "0.8.1"
[[constraint]] [[constraint]]
branch = "master" branch = "master"

View file

@ -17,7 +17,7 @@ import (
"time" "time"
"github.com/circonus-labs/circonus-gometrics/api" "github.com/circonus-labs/circonus-gometrics/api"
"github.com/hashicorp/go-retryablehttp" retryablehttp "github.com/hashicorp/go-retryablehttp"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@ -141,7 +141,8 @@ func (m *CirconusMetrics) trapCall(payload []byte) (int, error) {
client.CheckRetry = retryPolicy client.CheckRetry = retryPolicy
attempts := -1 attempts := -1
client.RequestLogHook = func(logger *log.Logger, req *http.Request, retryNumber int) { client.RequestLogHook = func(logger retryablehttp.Logger, req *http.Request, retryNumber int) {
//client.RequestLogHook = func(logger *log.Logger, req *http.Request, retryNumber int) {
attempts = retryNumber attempts = retryNumber
} }

View file

@ -36,7 +36,7 @@ import (
"strings" "strings"
"time" "time"
"github.com/hashicorp/go-cleanhttp" cleanhttp "github.com/hashicorp/go-cleanhttp"
) )
var ( var (
@ -81,6 +81,28 @@ func (r *Request) WithContext(ctx context.Context) *Request {
return r return r
} }
// BodyBytes allows accessing the request body. It is an analogue to
// http.Request's Body variable, but it returns a copy of the underlying data
// rather than consuming it.
//
// This function is not thread-safe; do not call it at the same time as another
// call, or at the same time this request is being used with Client.Do.
func (r *Request) BodyBytes() ([]byte, error) {
if r.body == nil {
return nil, nil
}
body, err := r.body()
if err != nil {
return nil, err
}
buf := new(bytes.Buffer)
_, err = buf.ReadFrom(body)
if err != nil {
return nil, err
}
return buf.Bytes(), nil
}
// NewRequest creates a new wrapped request. // NewRequest creates a new wrapped request.
func NewRequest(method, url string, rawBody interface{}) (*Request, error) { func NewRequest(method, url string, rawBody interface{}) (*Request, error) {
var err error var err error
@ -183,18 +205,24 @@ func NewRequest(method, url string, rawBody interface{}) (*Request, error) {
return &Request{body, httpReq}, nil return &Request{body, httpReq}, nil
} }
// Logger interface allows to use other loggers than
// standard log.Logger.
type Logger interface {
Printf(string, ...interface{})
}
// RequestLogHook allows a function to run before each retry. The HTTP // 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 which will be made, and the retry number (0 for the initial
// request) are available to users. The internal logger is exposed to // request) are available to users. The internal logger is exposed to
// consumers. // consumers.
type RequestLogHook func(*log.Logger, *http.Request, int) type RequestLogHook func(Logger, *http.Request, int)
// ResponseLogHook is like RequestLogHook, but allows running a function // ResponseLogHook is like RequestLogHook, but allows running a function
// on each HTTP response. This function will be invoked at the end of // on each HTTP response. This function will be invoked at the end of
// every HTTP request executed, regardless of whether a subsequent retry // every HTTP request executed, regardless of whether a subsequent retry
// needs to be performed or not. If the response body is read or closed // needs to be performed or not. If the response body is read or closed
// from this method, this will affect the response returned from Do(). // from this method, this will affect the response returned from Do().
type ResponseLogHook func(*log.Logger, *http.Response) type ResponseLogHook func(Logger, *http.Response)
// CheckRetry specifies a policy for handling retries. It is called // CheckRetry specifies a policy for handling retries. It is called
// following each request with the response and error values returned by // following each request with the response and error values returned by
@ -221,7 +249,7 @@ type ErrorHandler func(resp *http.Response, err error, numTries int) (*http.Resp
// like automatic retries to tolerate minor outages. // like automatic retries to tolerate minor outages.
type Client struct { type Client struct {
HTTPClient *http.Client // Internal HTTP client. HTTPClient *http.Client // Internal HTTP client.
Logger *log.Logger // Customer logger instance. Logger Logger // Customer logger instance.
RetryWaitMin time.Duration // Minimum time to wait RetryWaitMin time.Duration // Minimum time to wait
RetryWaitMax time.Duration // Maximum time to wait RetryWaitMax time.Duration // Maximum time to wait

3
vendor/github.com/hashicorp/go-retryablehttp/go.mod generated vendored Normal file
View file

@ -0,0 +1,3 @@
module github.com/hashicorp/go-retryablehttp
require github.com/hashicorp/go-cleanhttp v0.5.0

2
vendor/github.com/hashicorp/go-retryablehttp/go.sum generated vendored Normal file
View file

@ -0,0 +1,2 @@
github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig=
github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=

32
vendor/vendor.json vendored
View file

@ -763,28 +763,36 @@
"revisionTime": "2018-09-10T15:25:13Z" "revisionTime": "2018-09-10T15:25:13Z"
}, },
{ {
"checksumSHA1": "smALroa48uCO+J9JRlHBmz/XQMw=", "checksumSHA1": "H4RhrnI0P34qLB9345G4r7CAwpU=",
"path": "github.com/circonus-labs/circonus-gometrics", "path": "github.com/circonus-labs/circonus-gometrics",
"revision": "03033123293bfe2241d1f7e1a3de8fb508265251", "revision": "d6e3aea90ab9f90fe8456e13fc520f43d102da4d",
"revisionTime": "2018-09-28T18:16:22Z" "revisionTime": "2019-01-28T15:50:09Z",
"version": "v2.2.6",
"versionExact": "v2.2.6"
}, },
{ {
"checksumSHA1": "xtzLG2UjYF1lnD33Wk+Nu/KOO6E=", "checksumSHA1": "xtzLG2UjYF1lnD33Wk+Nu/KOO6E=",
"path": "github.com/circonus-labs/circonus-gometrics/api", "path": "github.com/circonus-labs/circonus-gometrics/api",
"revision": "03033123293bfe2241d1f7e1a3de8fb508265251", "revision": "d6e3aea90ab9f90fe8456e13fc520f43d102da4d",
"revisionTime": "2018-09-28T18:16:22Z" "revisionTime": "2019-01-28T15:50:09Z",
"version": "v2.2.6",
"versionExact": "v2.2.6"
}, },
{ {
"checksumSHA1": "bQhz/fcyZPmuHSH2qwC4ZtATy5c=", "checksumSHA1": "bQhz/fcyZPmuHSH2qwC4ZtATy5c=",
"path": "github.com/circonus-labs/circonus-gometrics/api/config", "path": "github.com/circonus-labs/circonus-gometrics/api/config",
"revision": "03033123293bfe2241d1f7e1a3de8fb508265251", "revision": "d6e3aea90ab9f90fe8456e13fc520f43d102da4d",
"revisionTime": "2018-09-28T18:16:22Z" "revisionTime": "2019-01-28T15:50:09Z",
"version": "v2.2.6",
"versionExact": "v2.2.6"
}, },
{ {
"checksumSHA1": "Ij8yB33E0Kk+GfTkNRoF1mG26dc=", "checksumSHA1": "Ij8yB33E0Kk+GfTkNRoF1mG26dc=",
"path": "github.com/circonus-labs/circonus-gometrics/checkmgr", "path": "github.com/circonus-labs/circonus-gometrics/checkmgr",
"revision": "03033123293bfe2241d1f7e1a3de8fb508265251", "revision": "d6e3aea90ab9f90fe8456e13fc520f43d102da4d",
"revisionTime": "2018-09-28T18:16:22Z" "revisionTime": "2019-01-28T15:50:09Z",
"version": "v2.2.6",
"versionExact": "v2.2.6"
}, },
{ {
"checksumSHA1": "2efAvf/xcfGiQ4Y1P3+5YObpeVg=", "checksumSHA1": "2efAvf/xcfGiQ4Y1P3+5YObpeVg=",
@ -1185,10 +1193,10 @@
"revisionTime": "2018-10-04T02:44:35Z" "revisionTime": "2018-10-04T02:44:35Z"
}, },
{ {
"checksumSHA1": "/yKfFSspjuDzyOe/bBslrPzyfYM=", "checksumSHA1": "9SqwC2BzFbsWulQuBG2+QEliTpo=",
"path": "github.com/hashicorp/go-retryablehttp", "path": "github.com/hashicorp/go-retryablehttp",
"revision": "e651d75abec6fbd4f2c09508f72ae7af8a8b7171", "revision": "73489d0a1476f0c9e6fb03f9c39241523a496dfd",
"revisionTime": "2018-07-18T19:50:05Z" "revisionTime": "2019-01-26T20:33:39Z"
}, },
{ {
"checksumSHA1": "A1PcINvF3UiwHRKn8UcgARgvGRs=", "checksumSHA1": "A1PcINvF3UiwHRKn8UcgARgvGRs=",