Documentation ¶
Overview ¶
Package keyrate wraps Limiter from golang.org/x/time/rate to perform key based limiting.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type IntLimiter ¶
type IntLimiter struct {
// contains filtered or unexported fields
}
An IntLimiter controls how often events are allowed to happen per int key.
func NewIntLimiter ¶
func NewIntLimiter(n rate.Limit, b int) *IntLimiter
NewIntLimiter returns a new IntLimiter with up to rate r and burts of at most b.
func (*IntLimiter) Allow ¶
func (l *IntLimiter) Allow(key int) bool
Allow reports whether one event may happen at time now for the provided key.
type StringLimiter ¶
type StringLimiter struct {
// contains filtered or unexported fields
}
A StringLimiter controls how often events are allowed to happen per string key.
func NewStringLimiter ¶
func NewStringLimiter(n rate.Limit, b int) *StringLimiter
NewStringLimiter returns a new StringLimiter with up to rate r and burts of at most b.
func (*StringLimiter) Allow ¶
func (l *StringLimiter) Allow(key string) bool
Allow reports whether one event may happen at time now for the provided key.
Click to show internal directories.
Click to hide internal directories.