Documentation ¶
Overview ¶
Package catrate implements multi-window rate limiting per (arbitrary) "category". Rates are applied independently, to all categories, with separate buckets per category. It uses a simple but potentially poorly optimized strategy, involving tracking discrete events, within a sliding window.
It is intended for use cases that don't lend themselves well to any of the more complex solutions, e.g. token buckets, sliding/fixed window counters, or probabilistic rate limiting (i.e. bloom filters).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
func (*Limiter) Allow ¶
Allow is a non-blocking call that attempts to register an event for the given category. True indicates that an event was registered. In all cases, the returned time is the next time that an event can be registered for the given category. If at least one more event may be registered prior to a rate limit being applied (at the current system time), the time will be the zero value.