Giter VIP home page Giter VIP logo

aiobreaker's Introduction

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.

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.6 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.

aiobreaker's People

Contributors

danielfm avatar arlyon avatar phillbaker avatar tczhaodachuan avatar jeffmadrid avatar chris-robo-fivestars avatar chrisvaughn avatar sadbot avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.