fastapi-cb
fastapi-cb is a Python implementation of the Circuit Breaker pattern,
described in Michael T. Nygard's book Release It!_.
Circuit breakers exist to allow one subsystem to fail without destroying the entire system. This is done by wrapping dangerous operations (typically integration points) with a component that can circumvent calls when the system is not healthy.
This project is a fork of aiobreaker by Alexander Lyon that add support for integration with FastAPI.
Features
- Works well with FastAPI framework
- Configurable list of excluded exceptions (e.g. business exceptions)
- Configurable failure threshold and reset timeout
- Support for several event listeners per circuit breaker
- Can guard generator functions
- Functions and properties for easy monitoring and management
asynciosupport- Optional redis backing
- Synchronous and asynchronous event listeners
Requirements
All you need is python 3.8 or higher.
Installation
To install, simply download from pypi:
pip install fastapi_cb
Usage
The first step is to create an instance of CircuitBreaker for each
integration point you want to protect against.
from fastapi_cb import CircuitBreaker
# Used in database integration points
db_breaker = CircuitBreaker(fail_max=5, reset_timeout=timedelta(seconds=60))
@db_breaker
async def outside_integration():
"""Hits the api"""
...
At that point, go ahead and get familiar with the documentation.
Metadata
Release files for fastapi-cb 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_cb-1.1.0.tar.gz | 16.0 kB | Without provenance | Details for fastapi_cb-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_cb-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for fastapi_cb-1.1.0-py3-none-any.whl |
Total release size: 36.7 kB
Release files / fastapi_cb-1.1.0.tar.gz
| Download URL | fastapi_cb-1.1.0.tar.gz |
|---|---|
| Size | 16.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ebe664f8b508fbb93b81f4aa95d3bac3a539ade7a0f881e488c3b3ae70508b79
|
|
BLAKE2b-256 checksum How to use checksums |
672e0363a1398271677c51fbff416b23e241f4559eb5b9c9488bc584327a5fc6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.4
|
Release files / fastapi_cb-1.1.0-py3-none-any.whl
| Download URL | fastapi_cb-1.1.0-py3-none-any.whl |
|---|---|
| Size | 20.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
295023d5782c943b8f4825630540915c5e0345dc91657807c5cc2c76862d650b
|
|
BLAKE2b-256 checksum How to use checksums |
a99e1dbc5fb9bf6526d3456745092e5779e826a18325041aa7333314f3fa5770
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.10.4
|
Security for fastapi-cb 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.