Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type IPRateLimiter ¶
type IPRateLimiter struct {
// contains filtered or unexported fields
}
IPRateLimiter imposes a rate limit per HTTP user IP.
func NewIPRateLimiter ¶
func NewIPRateLimiter(config IPRateLimiterConfig) *IPRateLimiter
NewIPRateLimiter constructs an IPRateLimiter.
func (*IPRateLimiter) Burst ¶
func (rl *IPRateLimiter) Burst() int
Burst returns the number of events that happen before the rate limit.
func (*IPRateLimiter) Duration ¶
func (rl *IPRateLimiter) Duration() time.Duration
Duration returns the amount of time required between events.
func (*IPRateLimiter) Limit ¶
func (rl *IPRateLimiter) Limit(next http.Handler) http.Handler
Limit applies a per IP rate limiting as an HTTP Handler.
func (*IPRateLimiter) Run ¶
func (rl *IPRateLimiter) Run(ctx context.Context)
Run occasionally cleans old rate-limiting data, until context cancel.
type IPRateLimiterConfig ¶
type IPRateLimiterConfig struct { Duration time.Duration `help:"the rate at which request are allowed" default:"5m"` Burst int `help:"number of events before the limit kicks in" default:"5" testDefault:"3"` NumLimits int `help:"number of IPs whose rate limits we store" default:"1000" testDefault:"10"` }
IPRateLimiterConfig configures an IPRateLimiter.
Click to show internal directories.
Click to hide internal directories.