mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 04:27:54 +00:00
godep: bump up juju/ratelimit
This commit is contained in:
parent
f9715c6455
commit
2edcd3abd5
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -549,7 +549,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/juju/ratelimit",
|
"ImportPath": "github.com/juju/ratelimit",
|
||||||
"Rev": "772f5c38e468398c4511514f4f6aa9a4185bc0a0"
|
"Rev": "77ed1c8a01217656d2080ad51981f6e99adaa177"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "github.com/kardianos/osext",
|
"ImportPath": "github.com/kardianos/osext",
|
||||||
|
26
Godeps/_workspace/src/github.com/juju/ratelimit/ratelimit.go
generated
vendored
26
Godeps/_workspace/src/github.com/juju/ratelimit/ratelimit.go
generated
vendored
@ -8,10 +8,10 @@
|
|||||||
package ratelimit
|
package ratelimit
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
"math"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Bucket represents a token bucket that fills at a predetermined rate.
|
// Bucket represents a token bucket that fills at a predetermined rate.
|
||||||
@ -171,6 +171,30 @@ func (tb *Bucket) takeAvailable(now time.Time, count int64) int64 {
|
|||||||
return count
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 (tb *Bucket) Available() int64 {
|
||||||
|
return tb.available(time.Now())
|
||||||
|
}
|
||||||
|
|
||||||
|
// available is the internal version of available - it takes the current time as
|
||||||
|
// an argument to enable easy testing.
|
||||||
|
func (tb *Bucket) available(now time.Time) int64 {
|
||||||
|
tb.mu.Lock()
|
||||||
|
defer tb.mu.Unlock()
|
||||||
|
tb.adjust(now)
|
||||||
|
return tb.avail
|
||||||
|
}
|
||||||
|
|
||||||
|
// Capacity returns the capacity that the bucket was created with.
|
||||||
|
func (tb *Bucket) Capacity() int64 {
|
||||||
|
return tb.capacity
|
||||||
|
}
|
||||||
|
|
||||||
// Rate returns the fill rate of the bucket, in tokens per second.
|
// Rate returns the fill rate of the bucket, in tokens per second.
|
||||||
func (tb *Bucket) Rate() float64 {
|
func (tb *Bucket) Rate() float64 {
|
||||||
return 1e9 * float64(tb.quantum) / float64(tb.fillInterval)
|
return 1e9 * float64(tb.quantum) / float64(tb.fillInterval)
|
||||||
|
Loading…
Reference in New Issue
Block a user