Documentation ¶
Overview ¶
Package ratelimit provides a basic token-bucket limiter for rosetta router. This can be used to prevent users from spamming the bot and overload discord API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bucket ¶
type Bucket struct {
// contains filtered or unexported fields
}
Bucket implements a simple bucket containing multiple tokens.
type Manager ¶
type Manager interface { // GetBucket returns a token-bucket rate limiter from given context. GetBucket(cmd rosetta.Command, uid, gid string) *Bucket // GetExecutions returns our internal execution mapping. GetExecutions() *timedmap.TimedMap }
Manager holds multiple buckets, act as an interface for rate limiter.
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements a managers of rate limiters. This can also be parsed a custom Manager instance if you want to handle limiters differently.
func (*RateLimiter) GetLayer ¶
func (r *RateLimiter) GetLayer() rosetta.MiddlewareLayer
Click to show internal directories.
Click to hide internal directories.