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:
committed by
Abhimanyu Saharan
parent
ee825fb2d5
commit
fc9fc1661c
12
backend/app/core/rate_limit_backend.py
Normal file
12
backend/app/core/rate_limit_backend.py
Normal 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"
|
||||
Reference in New Issue
Block a user