MCPcopy
hub / github.com/kubernetes/client-go / NewTokenBucketRateLimiter

Function NewTokenBucketRateLimiter

util/flowcontrol/throttle.go:49–52  ·  view source on GitHub ↗

NewTokenBucketRateLimiter creates a rate limiter which implements a token bucket approach. The rate limiter allows bursts of up to 'burst' to exceed the QPS, while still maintaining a smoothed qps rate of 'qps'. The bucket is initially filled with 'burst' tokens, and refills at a rate of 'qps'. The

(qps float32, burst int)

Source from the content-addressed store, hash-verified

47// The bucket is initially filled with 'burst' tokens, and refills at a rate of 'qps'.
48// The maximum number of tokens in the bucket is capped at 'burst'.
49func NewTokenBucketRateLimiter(qps float32, burst int) RateLimiter {
50 limiter := rate.NewLimiter(rate.Limit(qps), burst)
51 return newTokenBucketRateLimiter(limiter, realClock{}, qps)
52}
53
54// An injectable, mockable clock interface.
55type Clock interface {

Callers 6

NewForConfigFunction · 0.92
NewRESTClientFunction · 0.92
TestBasicThrottleFunction · 0.85
TestIncrementThrottleFunction · 0.85
TestThrottleFunction · 0.85

Calls 1

Tested by 4

TestBasicThrottleFunction · 0.68
TestIncrementThrottleFunction · 0.68
TestThrottleFunction · 0.68