Documentation
¶
Index ¶
Constants ¶
View Source
const (
// RateLimiterPrefix is the prefix of the rate limiter key
RateLimiterPrefix = "rate_limiter"
)
Variables ¶
View Source
var (
TooManyRequestsError = errors.New("Too many requests")
)
Functions ¶
This section is empty.
Types ¶
type DefaultRateLimiter ¶
type DefaultRateLimiter struct {
// contains filtered or unexported fields
}
DefaultRateLimiter struct
func NewDefaultRateLimiter ¶
func NewDefaultRateLimiter(redisClient *redis.Client, limit int, period time.Duration) *DefaultRateLimiter
NewDefaultRateLimiter creates a new rate limiter
func (*DefaultRateLimiter) Limit ¶
func (d *DefaultRateLimiter) Limit(ip string) error
Limit limits the rate of requests
Click to show internal directories.
Click to hide internal directories.