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"` FailureMode string `env:"RATE_LIMIT_FAILURE_MODE,default=closed"` // Redis configuration RedisHost string `env:"REDIS_HOST,default=127.0.0.1"` RedisPort string `env:"REDIS_PORT,default=6379"` RedisUsername string `env:"REDIS_USERNAME"` RedisPassword string `env:"REDIS_PASSWORD"` RedisMinPool uint64 `env:"REDIS_MIN_POOL,default=16"` RedisMaxPool uint64 `env:"REDIS_MAX_POOL,default=64"` }
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.