Skip to content

Instantly share code, notes, and snippets.

@vndee
Created December 25, 2024 08:06
Show Gist options
  • Save vndee/4c1f5c769e4fd30d33414f245ad09b79 to your computer and use it in GitHub Desktop.
Save vndee/4c1f5c769e4fd30d33414f245ad09b79 to your computer and use it in GitHub Desktop.
from redis_data_structures import ConnectionManager
from datetime import timedelta
conn = ConnectionManager(
host='redis.example.com',
max_connections=20,
retry_max_attempts=5,
circuit_breaker_threshold=10,
circuit_breaker_timeout=timedelta(minutes=5),
ssl=True
)
# The circuit breaker prevents cascade failures
try:
with conn.get_connection() as redis:
redis.ping()
except CircuitBreakerOpen:
# Handle degraded state gracefully
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment