Documentation
¶
Overview ¶
Package ratelimit limits events per key (an address, a user name) with a bounded memory: past the maximum, keys back to their initial state are dropped first (nothing is lost), then the least recently seen.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Keyed ¶
type Keyed[K comparable] struct { // contains filtered or unexported fields }
Keyed allows burst events at once per key, then one every period.
func New ¶
func New[K comparable](every time.Duration, burst, max int) *Keyed[K]
New returns a limiter keeping at most max keys.
Click to show internal directories.
Click to hide internal directories.