Update retryable dep

This commit is contained in:
Jeff Mitchell 2018-05-09 20:49:32 -04:00
parent a287830985
commit 2cc9b7fc72
2 changed files with 26 additions and 8 deletions

View file

@ -192,19 +192,37 @@ func DefaultBackoff(min, max time.Duration, attemptNum int, resp *http.Response)
// LinearJitterBackoff provides a callback for Client.Backoff which will
// perform linear backoff based on the attempt number and with jitter to
// prevent a thundering herd. The final backoff time is the attempt number
// multiplied by the random chosen value between min/max.
// prevent a thundering herd.
//
// min and max here are *not* absolute values. The number to be multipled by
// the attempt number will be chosen at random from between them, thus they are
// bounding the jitter.
//
// For instance:
// * To get strictly linear backoff of one second increasing each retry, set
// both to one second (1s, 2s, 3s, 4s, ...)
// * To get a small amount of jitter centered around one second increasing each
// retry, set to around one second, such as a min of 800ms and max of 1200ms
// (892ms, 2102ms, 2945ms, 4312ms, ...)
// * To get extreme jitter, set to a very wide spread, such as a min of 100ms
// and a max of 20s (15382ms, 292ms, 51321ms, 35234ms, ...)
func LinearJitterBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
// attemptNum always starts at zero but we want to start at 1 for multiplication
attemptNum++
if max <= min {
// Unclear what to do here, so return min
return min
// Unclear what to do here, or they are the same, so return min *
// attemptNum
return min * attemptNum
}
// Seed rand; doing this every time is fine
rand := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
// Pick a random number that lies somewhere between the min and max and
// multiply by the attemptNum. attemptNum starts at zero so we always
// increment here.
return (min + time.Duration(int64(rand.Int63())%int64(max-min))) * time.Duration(attemptNum+1)
return time.Duration((rand.Int63() % int64(max-min)) * attemptNum)
}
// PassthroughErrorHandler is an ErrorHandler that directly passes through the

6
vendor/vendor.json vendored
View file

@ -1141,10 +1141,10 @@
"revisionTime": "2018-03-31T00:25:53Z"
},
{
"checksumSHA1": "xCptnjI2GVTNvx+Td5enr9jvk4w=",
"checksumSHA1": "Zg/eHcBFPznCeqiRBQeV8WQw9G8=",
"path": "github.com/hashicorp/go-retryablehttp",
"revision": "0936e5acf1e32bbc3c210de331a1aefb3a2113bc",
"revisionTime": "2018-05-09T22:33:19Z"
"revision": "936ce55c28f313d8cf79061ffcb25a55bf631eb6",
"revisionTime": "2018-05-10T00:49:21Z"
},
{
"checksumSHA1": "A1PcINvF3UiwHRKn8UcgARgvGRs=",