feat: add Redis-backed rate limiter with configurable backend

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>
This commit is contained in:
Hugh Brown
2026-03-04 02:15:14 -07:00
committed by Abhimanyu Saharan
parent ee825fb2d5
commit fc9fc1661c
5 changed files with 385 additions and 14 deletions

View File

@@ -0,0 +1,12 @@
"""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"