Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
A Bucket represents a simple token bucket based rate limiter. Token buckets act as a reservoir with a fixed capacity. In order to perform a rate limited operation, a token must be acquired from the bucket. If sufficient tokens are available, the operation preceeds immediately and those tokens are removed from the bucket. If sufficient tokens are not available the operation is blocked.
See: https://en.wikipedia.org/wiki/Token_bucket
func ConstantRPM ¶
ConstantRPM returns a new token bucket targeting n requests per minute.
Click to show internal directories.
Click to hide internal directories.