diff options
author | Wim <wim@42.be> | 2017-11-02 17:09:34 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-11-02 17:09:34 +0100 |
commit | b2a6777995c55233a47212743c781a27dde8dce6 (patch) | |
tree | be4a9ef00448f82c71ae47d42835347160b70900 /vendor/github.com/nlopes/slack/backoff.go | |
parent | b461fc5e404c6e0df7289477171cad629cddb3e6 (diff) | |
download | matterbridge-msglm-b2a6777995c55233a47212743c781a27dde8dce6.tar.gz matterbridge-msglm-b2a6777995c55233a47212743c781a27dde8dce6.tar.bz2 matterbridge-msglm-b2a6777995c55233a47212743c781a27dde8dce6.zip |
Use matterbridge vendored slack
Diffstat (limited to 'vendor/github.com/nlopes/slack/backoff.go')
-rw-r--r-- | vendor/github.com/nlopes/slack/backoff.go | 57 |
1 files changed, 0 insertions, 57 deletions
diff --git a/vendor/github.com/nlopes/slack/backoff.go b/vendor/github.com/nlopes/slack/backoff.go deleted file mode 100644 index e555a1ad..00000000 --- a/vendor/github.com/nlopes/slack/backoff.go +++ /dev/null @@ -1,57 +0,0 @@ -package slack - -import ( - "math" - "math/rand" - "time" -) - -// This one was ripped from https://github.com/jpillora/backoff/blob/master/backoff.go - -// Backoff is a time.Duration counter. It starts at Min. After every -// call to Duration() it is multiplied by Factor. It is capped at -// Max. It returns to Min on every call to Reset(). Used in -// conjunction with the time package. -type backoff struct { - attempts int - //Factor is the multiplying factor for each increment step - Factor float64 - //Jitter eases contention by randomizing backoff steps - Jitter bool - //Min and Max are the minimum and maximum values of the counter - Min, Max time.Duration -} - -// Returns the current value of the counter and then multiplies it -// Factor -func (b *backoff) Duration() time.Duration { - //Zero-values are nonsensical, so we use - //them to apply defaults - if b.Min == 0 { - b.Min = 100 * time.Millisecond - } - if b.Max == 0 { - b.Max = 10 * time.Second - } - if b.Factor == 0 { - b.Factor = 2 - } - //calculate this duration - dur := float64(b.Min) * math.Pow(b.Factor, float64(b.attempts)) - if b.Jitter == true { - dur = rand.Float64()*(dur-float64(b.Min)) + float64(b.Min) - } - //cap! - if dur > float64(b.Max) { - return b.Max - } - //bump attempts count - b.attempts++ - //return as a time.Duration - return time.Duration(dur) -} - -//Resets the current value of the counter back to Min -func (b *backoff) Reset() { - b.attempts = 0 -} |