Documentation ¶
Index ¶
Constants ¶
View Source
const Inf = Limit(math.MaxFloat64)
Inf is the infinite rate limit; it allows all events (even if burst is zero).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Limit defines the maximum frequency of some events. // Limit is represented as number of events per second. // A zero Limit allows no events. Limit Limit // the capacity of the bucket Capacity int64 }
Config is the bucket configuration.
type Limit ¶
type Limit float64
Limit defines the maximum frequency of some events. Limit is represented as number of events per second. A zero Limit allows no events.
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter implements the Token Bucket Algorithm. See https://en.wikipedia.org/wiki/Token_bucket.
func NewLimiter ¶
NewLimiter returns a new token-bucket rate limiter special for key in redis with the specified bucket configuration.
func (*Limiter) Config ¶
func (b *Limiter) Config() Config
Config returns the bucket configuration in a concurrency-safe way.
func (*Limiter) SetConfig ¶
func (b *Limiter) SetConfig(config *Config)
SetConfig updates the bucket configuration in a concurrency-safe way.
type RedisClient ¶
type Reservation ¶
Click to show internal directories.
Click to hide internal directories.