Documentation ¶
Index ¶
- type Config
- type Limiter
- func (l *Limiter) Allowed(key string) bool
- func (l *Limiter) Disallowed(key string) bool
- func (l *Limiter) Do(key string) bool
- func (l *Limiter) DoWait(key string)
- func (l *Limiter) Dont(key string) bool
- func (l *Limiter) HowLong(key string) time.Duration
- func (l *Limiter) Limit(key string)
- func (l *Limiter) XDo(key string, dur time.Duration) bool
- func (l *Limiter) XDoWait(key string, period time.Duration)
- func (l *Limiter) XDont(key string, dur time.Duration) bool
- func (l *Limiter) XLimit(key string, dur time.Duration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // If false it will only set a new limit if the action is allowed to happen // If true then they will set the limit period regardless SetWhenLimited bool // the timer period before limits are clear Period time.Duration }
Config for the ratelimiter
type Limiter ¶
type Limiter struct { Config // contains filtered or unexported fields }
Limiter is a ratelimit management thingy
func (*Limiter) Allowed ¶
Allowed returns if an action is allowed to happen but does not set a new limit
func (*Limiter) Disallowed ¶
Disallowed is the inverse of Allowed
func (*Limiter) Do ¶
Do returns if an action is allowed to happen at this moment, and sets a new limit
Click to show internal directories.
Click to hide internal directories.