Metadata-Version: 2.5
Name: aiobreaker-redis
Version: 0.1.0
Summary: Distributed async circuit breaker for Python asyncio, httpx, and FastAPI with Redis state synchronization.
Project-URL: Homepage, https://github.com/authoritydmc/aiobreaker-redis
Project-URL: Repository, https://github.com/authoritydmc/aiobreaker-redis.git
Author-email: Raj Dubey <com.mailuser@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: asyncio,circuit-breaker,distributed,fastapi,httpx,redis,resilience
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Requires-Dist: redis>=4.5.0
Description-Content-Type: text/markdown

# aiobreaker-redis

> 🛡 Distributed async circuit breaker for Python `asyncio`, `httpx`, and `FastAPI` with Redis state synchronization.

[![PyPI version](https://img.shields.io/pypi/v/aiobreaker-redis.svg)](https://pypi.org/project/aiobreaker-redis/)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

---

## 💡 Features

- ⚡️ **Pure `asyncio` First:** Zero blocking I/O, built natively for Python async/await applications.
- 🌐 **Distributed Redis State:** Synchronize circuit breaker status (`CLOSED`, `OPEN`, `HALF_OPEN`) across multiple Gunicorn/Uvicorn worker processes and Kubernetes pods.
- 🎯 **Fast Fallbacks:** Execute sync or async fallbacks instantly when circuits trip open.
- 🚀 **FastAPI & `httpx` Ready:** Clean `@breaker.wrap(fallback=...)` decorator for API endpoints and HTTP client wrappers.

---

## 📦 Installation

```bash
pip install aiobreaker-redis
```

---

## 🚀 Quick Usage

```python
import httpx
from aiobreaker_redis import CircuitBreaker, CircuitOpenError

breaker = CircuitBreaker(
    name="payment-gateway",
    failure_threshold=5,
    recovery_timeout=30.0,
    # Optional redis client:
    # redis_client=redis_client
)

async def payment_fallback():
    return {"status": "queued", "message": "Payment service temporarily unavailable"}

@breaker.wrap(fallback=payment_fallback)
async def charge_card(amount: float):
    async with httpx.AsyncClient() as client:
        response = await client.post("https://api.payments.com/charge", json={"amount": amount})
        response.raise_for_status()
        return response.json()
```

---

## 📄 License

MIT © Raj Dubey
