diff options
| author | Teddy Wing | 2022-09-20 21:00:42 +0200 |
|---|---|---|
| committer | Teddy Wing | 2022-09-20 21:00:42 +0200 |
| commit | 2cc79c6873dc59b0510045717b0359bc64513fc1 (patch) | |
| tree | cdac0f9a3671cc21374f43d1d5dae829e021737c /vendor/google.golang.org/api/gensupport/backoff.go | |
| parent | 426afbfbee72c8c1e66c67c6837f62a9f5633698 (diff) | |
| download | gdrive-2cc79c6873dc59b0510045717b0359bc64513fc1.tar.bz2 | |
Untrack and ignore the vendor directory
I don't think this should be in version control.
Diffstat (limited to 'vendor/google.golang.org/api/gensupport/backoff.go')
| -rw-r--r-- | vendor/google.golang.org/api/gensupport/backoff.go | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/vendor/google.golang.org/api/gensupport/backoff.go b/vendor/google.golang.org/api/gensupport/backoff.go deleted file mode 100644 index 1356140..0000000 --- a/vendor/google.golang.org/api/gensupport/backoff.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package gensupport - -import ( - "math/rand" - "time" -) - -type BackoffStrategy interface { - // Pause returns the duration of the next pause and true if the operation should be - // retried, or false if no further retries should be attempted. - Pause() (time.Duration, bool) - - // Reset restores the strategy to its initial state. - Reset() -} - -// ExponentialBackoff performs exponential backoff as per https://en.wikipedia.org/wiki/Exponential_backoff. -// The initial pause time is given by Base. -// Once the total pause time exceeds Max, Pause will indicate no further retries. -type ExponentialBackoff struct { - Base time.Duration - Max time.Duration - total time.Duration - n uint -} - -func (eb *ExponentialBackoff) Pause() (time.Duration, bool) { - if eb.total > eb.Max { - return 0, false - } - - // The next pause is selected from randomly from [0, 2^n * Base). - d := time.Duration(rand.Int63n((1 << eb.n) * int64(eb.Base))) - eb.total += d - eb.n++ - return d, true -} - -func (eb *ExponentialBackoff) Reset() { - eb.n = 0 - eb.total = 0 -} |
