fastapi-limiter icon indicating copy to clipboard operation
fastapi-limiter copied to clipboard

Add circuitbreaker pattern to the rate limiter

Open yarjor opened this issue 1 year ago • 0 comments

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.

yarjor avatar Mar 29 '25 11:03 yarjor