package ratelimit
import "k8s.io/client-go/pkg/util/ratelimit"
Index ¶
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket models a token bucket
func NewBucketWithRate ¶
NewBucketWithRate creates a new token bucket, with maximum capacity = initial capacity, and a refill rate of qps We use floats for refill calculations, which introduces the possibility of truncation and rounding errors. For "sensible" qps values though, is is acceptable: jbeda did some tests here https://play.golang.org/p/LSKUOGz2LG
func (*Bucket) Available ¶
Available returns the quantity available in the bucket (which may be negative), but does not take it. This function is for diagnostic / informational purposes only - the returned capacity may immediately be inaccurate if another thread is operating on the bucket concurrently.
func (*Bucket) Capacity ¶
Capacity returns the maximum capacity of the bucket
func (*Bucket) Take ¶
Take takes n units from the bucket, reducing the available quantity even below zero, but then returns the amount of time we should wait
func (*Bucket) TakeAvailable ¶
TakeAvailable immediately takes whatever quantity is available, up to max
func (*Bucket) Wait ¶
Wait combines a call to Take with a sleep call
Source Files ¶
bucket.go
- Version
- v2.0.0-alpha.1+incompatible
- Published
- Dec 20, 2016
- Platform
- js/wasm
- Imports
- 3 packages
- Last checked
- 3 minutes ago –
Tools for package owners.