https://github.com/arlyon/aiobreaker
Python implementation of the Circuit Breaker pattern.
https://github.com/arlyon/aiobreaker
asyncio circuit-breaker hacktoberfest python
Last synced: 6 months ago
JSON representation
Python implementation of the Circuit Breaker pattern.
- Host: GitHub
- URL: https://github.com/arlyon/aiobreaker
- Owner: arlyon
- License: bsd-3-clause
- Created: 2018-07-27T19:21:54.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2022-01-01T19:27:38.000Z (almost 4 years ago)
- Last Synced: 2025-04-30T08:14:13.618Z (6 months ago)
- Topics: asyncio, circuit-breaker, hacktoberfest, python
- Language: Python
- Homepage: https://aiobreaker.netlify.com/
- Size: 147 KB
- Stars: 21
- Watchers: 3
- Forks: 6
- Open Issues: 5
-
Metadata Files:
- Readme: readme.rst
- Changelog: changelog.rst
- Contributing: contributing.rst
- License: license.md
Awesome Lists containing this project
README
aiobreaker
==========aiobreaker 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 that
replaces tornado with native asyncio, originally so I could practice
packaging and learn about that shiny new ``typing`` package... _`Release It!`: https://pragprog.com/titles/mnee2/release-it-second-edition/
.. _pybreaker: https://github.com/danielfm/pybreakerFeatures
--------- 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
- ``asyncio`` support
- Optional redis backing
- Synchronous and asynchronous event listenersRequirements
------------All you need is ``python 3.6`` or higher.
Installation
------------To install, simply download from pypi:
.. code:: bash
pip install aiobreaker
Usage
-----The first step is to create an instance of ``CircuitBreaker`` for each
integration point you want to protect against... code:: python
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.