fastapi-limiter
fastapi-limiter copied to clipboard
Add circuitbreaker pattern to the rate limiter
Added an option to apply a circuit breaker to the rate limiter, in order to better handle temporary unavailability of Redis (as raised in #54 )
@app.get(
"/circuit-breaker",
dependencies=[Depends(RateLimiter(times=1, seconds=5, circuit_breaker=(2, 5)))])
async def circuit_breaker():
return {"msg": "Hello World"}
# This example will stop ratelimiting on the second connection error,
# and retry after 5 seconds.