Documentation
¶
Index ¶
Constants ¶
View Source
const ( OnceTakeCount = 1 OncePutCount = 1 DefaultFillInterval = 50 * time.Millisecond DefaultCapacity = 10000 DefaultQuantum = 500 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
func NewRateLimiter ¶
func NewRateLimiter(fillInterval time.Duration, capacity int64) *RateLimiter
returns a new token bucket that fills at the rate of one token every fillInterval, up to the given maximum capacity.Both arguments must be positive. The bucket is initially full.
func NewRateLimiterWithQuantum ¶
func NewRateLimiterWithQuantum(fillInterval time.Duration, capacity, quantum int64) *RateLimiter
allows the specification of the quantum size - quantum tokens are added every fillInterval.
func (*RateLimiter) Limit ¶
func (l *RateLimiter) Limit() bool
Click to show internal directories.
Click to hide internal directories.