Add RedisRateLimiter using sorted-set sliding window alongside the existing InMemoryRateLimiter. Users choose via RATE_LIMIT_BACKEND (memory|redis) with RATE_LIMIT_REDIS_URL falling back to RQ_REDIS_URL. Redis backend validates connectivity at startup and fails open on transient errors during requests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
13 lines
224 B
Python
13 lines
224 B
Python
"""Rate-limit backend selection enum."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from enum import Enum
|
|
|
|
|
|
class RateLimitBackend(str, Enum):
|
|
"""Supported rate-limiting backends."""
|
|
|
|
MEMORY = "memory"
|
|
REDIS = "redis"
|