Documentation ¶
Index ¶
- func Default() gin.HandlerFunc
- func Limit(c int, r rate.Limit, b int) gin.HandlerFunc
- type Limiter
- func (l *Limiter) Allow(key string) bool
- func (l *Limiter) Burst(key string) (b int, ok bool)
- func (l *Limiter) Limit(key string) (r rate.Limit, ok bool)
- func (l *Limiter) ServeHTTP(c *gin.Context)
- func (l *Limiter) Set(key string)
- func (l *Limiter) SetBurst(key string, newBurst int)
- func (l *Limiter) SetLimit(key string, newLimit rate.Limit)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Default ¶
func Default() gin.HandlerFunc
Default create a new Limiter with default Limit params.
Types ¶
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter combines the IRU algorithm to rate limit. A Limiter is a cache where all keyed limiter stored.
func New ¶
New new a Limiter that allows each keyed limiter up to rate r and permits bursts of at most b tokens.
func (*Limiter) Allow ¶
Allow reports whether a event happens now. If the keyed limiter of the event does not exist in the cache, set a new keyed limiter to the cache.
Click to show internal directories.
Click to hide internal directories.