Skip to main content

Python implementation of the Circuit Breaker pattern.

Project description

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/mnee/release-it .. _pybreaker: https://github.com/danielfm/pybreaker

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
  • asyncio support
  • Optional redis backing
  • Synchronous and asynchronous event listeners

Requirements

All you need is python 3.5 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiobreaker-1.1.0.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

aiobreaker-1.1.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file aiobreaker-1.1.0.tar.gz.

File metadata

  • Download URL: aiobreaker-1.1.0.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.1

File hashes

Hashes for aiobreaker-1.1.0.tar.gz
Algorithm Hash digest
SHA256 2d4f70f1615b1543ac81633be52869aa640760b32b8cd083d6357f6499dfa402
MD5 0bf724a9ebba4b7d1c4f3691bf601bb2
BLAKE2b-256 c3cae5207773e6b2c937dcc22d4bcc4f2eed4287f351e104e9aa0c5457b84fd2

See more details on using hashes here.

File details

Details for the file aiobreaker-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: aiobreaker-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 20.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.1

File hashes

Hashes for aiobreaker-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f8077c31bcd0348d076dfcee893bf23fb2897bd5ab1759e34b1ca20ccadaf57
MD5 33530d33171096443c8723cea835c75c
BLAKE2b-256 e1e0e3e1560a6b110de7bacf7c2b2565d6e8196e05ed94eb2a6382a7249d1012

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page