Python implementation of the Circuit Breaker pattern.
Project description
AioBreaker
PyBreaker 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 pybreaker by Daniel Fernandes Martins for a few reasons:
- learning python packaging
- learning python testing
- learning python documentation
- significant refactor when supporting asyncio
- removal of tornado support
- removal of python 2.7 - 3.4 support
Features
- 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
- Thread-safe
- Asyncio support
- Optional redis backing
Requirements
All you need is python 3.5
or higher.
Installation
To install, simply download from pypi:
$ pip install aiobreaker
Usage
The first step is to create an instance of CircuitBreaker
for each
integration point you want to protect against.
from aiobreaker 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file aiobreaker-1.0.0.tar.gz
.
File metadata
- Download URL: aiobreaker-1.0.0.tar.gz
- Upload date:
- Size: 14.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6a826488f31e8685d9fc160c8b5e046f5d0dd8a764b1f20d44a763ba6bb1a16 |
|
MD5 | 68de2388cfc177e875e3e138535d8059 |
|
BLAKE2b-256 | ad85900c3202fb82e807dc7fe3bb1abcbf219b1cc72788e3503c0696b276e26a |
File details
Details for the file aiobreaker-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: aiobreaker-1.0.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.7.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cc8608c9d2fb9af5d859235b8f53e8750e83d9f46957581dfbc25257af0eff1 |
|
MD5 | b2a77ecf7f002f6f94dd16d856dd8bad |
|
BLAKE2b-256 | b535e3a03359b3d8ea4d6fa56b3ffabe103bf9bead3bbc069f594c9646fe1814 |