Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter rate limiter with ttl
func NewRateLimiter ¶
NewRateLimiter create rate limiter with ttl, every *rate.Limiter allows events up to rate limit and permits bursts of at most b tokens.
func (RateLimiter) Allow ¶
func (th RateLimiter) Allow(item string) bool
Allow is shorthand for getLimiter(item).Allow().
func (RateLimiter) OnEvicted ¶
func (th RateLimiter) OnEvicted(fn func(item string, lim *rate.Limiter))
OnEvicted a callback function called when lim is purged from the cache.
func (RateLimiter) Reserve ¶
func (th RateLimiter) Reserve(item string) *rate.Reservation
Reserve is shorthand for getLimiter(item).Reserve().
Click to show internal directories.
Click to hide internal directories.