diff options
author | Christopher Speller <crspeller@gmail.com> | 2018-06-21 13:10:40 -0700 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2018-06-21 16:10:40 -0400 |
commit | 8526739066ccb00ccd24b74650a7d7b284442985 (patch) | |
tree | 282512ae2ad95c98a9ca82de304a410b6b56685c /vendor/gopkg.in/throttled/throttled.v2/deprecated.go | |
parent | a59ccaa8b3844895dde3980e6224fef46ff4a1c8 (diff) | |
download | chat-8526739066ccb00ccd24b74650a7d7b284442985.tar.gz chat-8526739066ccb00ccd24b74650a7d7b284442985.tar.bz2 chat-8526739066ccb00ccd24b74650a7d7b284442985.zip |
MM-10934 Update server dependencies. (#8981)
* Changing throttled import path.
* Upgrading dependencies.
Diffstat (limited to 'vendor/gopkg.in/throttled/throttled.v2/deprecated.go')
-rw-r--r-- | vendor/gopkg.in/throttled/throttled.v2/deprecated.go | 73 |
1 files changed, 0 insertions, 73 deletions
diff --git a/vendor/gopkg.in/throttled/throttled.v2/deprecated.go b/vendor/gopkg.in/throttled/throttled.v2/deprecated.go deleted file mode 100644 index f2c648a3e..000000000 --- a/vendor/gopkg.in/throttled/throttled.v2/deprecated.go +++ /dev/null @@ -1,73 +0,0 @@ -package throttled - -import ( - "net/http" - "time" -) - -// DEPRECATED. Quota returns the number of requests allowed and the custom time window. -func (q Rate) Quota() (int, time.Duration) { - return q.count, q.period * time.Duration(q.count) -} - -// DEPRECATED. Q represents a custom quota. -type Q struct { - Requests int - Window time.Duration -} - -// DEPRECATED. Quota returns the number of requests allowed and the custom time window. -func (q Q) Quota() (int, time.Duration) { - return q.Requests, q.Window -} - -// DEPRECATED. The Quota interface defines the method to implement to describe -// a time-window quota, as required by the RateLimit throttler. -type Quota interface { - // Quota returns a number of requests allowed, and a duration. - Quota() (int, time.Duration) -} - -// DEPRECATED. Throttler is a backwards-compatible alias for HTTPLimiter. -type Throttler struct { - HTTPRateLimiter -} - -// DEPRECATED. Throttle is an alias for HTTPLimiter#Limit -func (t *Throttler) Throttle(h http.Handler) http.Handler { - return t.RateLimit(h) -} - -// DEPRECATED. RateLimit creates a Throttler that conforms to the given -// rate limits -func RateLimit(q Quota, vary *VaryBy, store GCRAStore) *Throttler { - count, period := q.Quota() - - if count < 1 { - count = 1 - } - if period <= 0 { - period = time.Second - } - - rate := Rate{period: period / time.Duration(count)} - limiter, err := NewGCRARateLimiter(store, RateQuota{rate, count - 1}) - - // This panic in unavoidable because the original interface does - // not support returning an error. - if err != nil { - panic(err) - } - - return &Throttler{ - HTTPRateLimiter{ - RateLimiter: limiter, - VaryBy: vary, - }, - } -} - -// DEPRECATED. Store is an alias for GCRAStore -type Store interface { - GCRAStore -} |