Documentation
¶
Overview ¶
Package ratelimit defines common rate limiting logic and config.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Common configuration
Type RateLimitType `env:"RATE_LIMIT_TYPE, default=NOOP"`
Tokens uint64 `env:"RATE_LIMIT_TOKENS, default=60"`
Interval time.Duration `env:"RATE_LIMIT_INTERVAL, default=1m"`
// HMACKey is the key to use when calculating the HMAC of keys before saving
// them in the rate limiter.
HMACKey envconfig.Base64Bytes `env:"RATE_LIMIT_HMAC_KEY, required"`
// Redis configuration
Redis redis.Config `env:",prefix=RATE_LIMIT_"`
}
Config represents rate limiting configuration
type RateLimitType ¶
type RateLimitType string
RateLimitType represents a type of rate limiter.
const ( RateLimiterTypeNoop RateLimitType = "NOOP" RateLimiterTypeMemory RateLimitType = "MEMORY" RateLimiterTypeRedis RateLimitType = "REDIS" )
Click to show internal directories.
Click to hide internal directories.