Skip to main content

A circuit breaker implementation for asyncio

Project description

Documentation Status Continuous Integration Status Code Coverage Report

Purgatory is an implementation of the circuit breaker pattern.

Why another Circuit Breaker implementation ?

The Purgatory library has been develop to be used in blacksmith where the library aiobreaker was used but I encountered limitation so, I decide to build my own implementation that feet well with blacksmith.

Features

Purgatory supports the creation of many circuit breakers easily, that can be used as context manager or decorator. Circuit breaker can be asynchronous or synchronous.

Example with a context manager for an async API

from purgatory import AsyncCircuitBreakerFactory

circuitbreaker = AsyncCircuitBreakerFactory()
async with await circuitbreaker.get_breaker("my_circuit"):
   ...

Example with a decorator

from purgatory import AsyncCircuitBreakerFactory

circuitbreaker = AsyncCircuitBreakerFactory()

@circuitbreaker("another circuit")
async def function_that_may_fail():
   ...

Example with a context manager for an synchronous API

from purgatory import SyncCircuitBreakerFactory

circuitbreaker = SyncCircuitBreakerFactory()
with circuitbreaker.get_breaker("my_circuit"):
   ...

Circuit breakers states and monitoring

The state of every circuits can be stored in memory, shared in redis, or be completly customized.

It also support monitoring, using event hook.

Purgatory is fully typed and fully tested.

Read More

You can read the full documentation of this library here.

Alternatives

Here is a list of alternatives, which may or may not support coroutines.

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

purgatory-1.0.1.tar.gz (12.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

purgatory-1.0.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file purgatory-1.0.1.tar.gz.

File metadata

  • Download URL: purgatory-1.0.1.tar.gz
  • Upload date:
  • Size: 12.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.17.9-arch1-1

File hashes

Hashes for purgatory-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3aa62b4c7dffc0aa4f679678809dd723ced9dace12b72f67c4f97d992dc467f0
MD5 b74055319753c4f52dcf046ee19f6096
BLAKE2b-256 8b1018fb51c86120b6c7859929df4697fd2d5cb01baaf5d18766d30a873f81cd

See more details on using hashes here.

File details

Details for the file purgatory-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: purgatory-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 19.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.10.4 Linux/5.17.9-arch1-1

File hashes

Hashes for purgatory-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6babf4bbb6bf914012052600dd1d7b29ad2c375acc1302f27a310b77c56a2093
MD5 e1e33d33e8a06c1fe87832bacc06f701
BLAKE2b-256 05836d31e31c7581ad36172722498c964c739b4d607a54865e14c727b4fbc195

See more details on using hashes here.

Supported by

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