Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyRateLimiter ¶
type APIKeyRateLimiter struct {
// contains filtered or unexported fields
}
APIKeyRateLimiter manages rate limits per API key
func NewAPIKeyRateLimiter ¶
func NewAPIKeyRateLimiter() *APIKeyRateLimiter
NewAPIKeyRateLimiter creates a new API key-based rate limiter
func (*APIKeyRateLimiter) Allow ¶
func (rl *APIKeyRateLimiter) Allow(apiKey string) (bool, error)
Allow checks if a request with an API key is allowed
func (*APIKeyRateLimiter) SetLimit ¶
func (rl *APIKeyRateLimiter) SetLimit(apiKey string, config RateLimitConfig)
SetLimit sets the rate limit for an API key
type IPRateLimiter ¶
type IPRateLimiter struct {
// contains filtered or unexported fields
}
IPRateLimiter manages rate limits per IP address
func NewIPRateLimiter ¶
func NewIPRateLimiter(maxTokens, refillRate float64) *IPRateLimiter
NewIPRateLimiter creates a new IP-based rate limiter
func (*IPRateLimiter) Allow ¶
func (rl *IPRateLimiter) Allow(ip string) bool
Allow checks if a request from an IP is allowed
type RateLimitConfig ¶
RateLimitConfig defines rate limit configuration
type RateLimiter ¶
type RateLimiter struct {
// contains filtered or unexported fields
}
RateLimiter implements a token bucket rate limiter
func NewRateLimiter ¶
func NewRateLimiter(maxTokens float64, refillRate float64) *RateLimiter
NewRateLimiter creates a new rate limiter
func (*RateLimiter) Allow ¶
func (rl *RateLimiter) Allow() bool
Allow checks if a request is allowed
func (*RateLimiter) AllowN ¶
func (rl *RateLimiter) AllowN(n float64) bool
AllowN checks if n requests are allowed
Click to show internal directories.
Click to hide internal directories.