Browse Source

Updated vendored ratelimit

Rod Hynes 6 years ago
parent
commit
090bd9cdd1

+ 12 - 0
vendor/github.com/juju/ratelimit/README.md

@@ -60,6 +60,18 @@ rate tokens per second up to the given maximum capacity. Because of limited
 clock resolution, at high rates, the actual rate may be up to 1% different from
 the specified rate.
 
+#### func (*Bucket) Available
+
+```go
+func (tb *Bucket) Available() int64
+```
+Available returns the number of available tokens. It will be negative
+when there are consumers waiting for tokens. Note that if this
+returns greater than zero, it does not guarantee that calls that take
+tokens from the buffer will succeed, as the number of available
+tokens could have changed in the meantime. This method is intended
+primarily for metrics reporting and debugging.
+
 #### func (*Bucket) Rate
 
 ```go

+ 3 - 2
vendor/github.com/juju/ratelimit/ratelimit.go

@@ -310,14 +310,15 @@ func (tb *Bucket) currentTick(now time.Time) int64 {
 // available in the bucket at the given time, which must
 // be in the future (positive) with respect to tb.latestTick.
 func (tb *Bucket) adjustavailableTokens(tick int64) {
+	lastTick := tb.latestTick
+	tb.latestTick = tick
 	if tb.availableTokens >= tb.capacity {
 		return
 	}
-	tb.availableTokens += (tick - tb.latestTick) * tb.quantum
+	tb.availableTokens += (tick - lastTick) * tb.quantum
 	if tb.availableTokens > tb.capacity {
 		tb.availableTokens = tb.capacity
 	}
-	tb.latestTick = tick
 	return
 }
 

+ 3 - 3
vendor/vendor.json

@@ -249,10 +249,10 @@
 			"revisionTime": "2018-02-01T23:52:37Z"
 		},
 		{
-			"checksumSHA1": "dqtKfXGotqkiYaS328PpWeusig8=",
+			"checksumSHA1": "z8MqG1rnemNMAoCpATKO9HpA0M8=",
 			"path": "github.com/juju/ratelimit",
-			"revision": "59fac5042749a5afb9af70e813da1dd5474f0167",
-			"revisionTime": "2017-10-26T09:04:26Z"
+			"revision": "f60b32039441cd828005f82f3a54aafd00bc9882",
+			"revisionTime": "2019-10-02T06:26:51Z"
 		},
 		{
 			"checksumSHA1": "gEjGS03N1eysvpQ+FCHTxPcbxXc=",