Purgatory#
Purgatory is an implementation of the circuit breaker pattern.
Note
It is used to detect failures and encapsulates the logic of preventing a failure from constantly recurring, during maintenance, temporary external system failure or unexpected system difficulties.
Source: https://en.wikipedia.org/wiki/Circuit_breaker_design_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.
Important
Alternatives#
Here is a list of alternatives, which may or may not support coroutines.
aiobreaker - https://pypi.org/project/aiobreaker/
circuitbreaker - https://pypi.org/project/circuitbreaker/
pycircuitbreaker - https://pypi.org/project/pycircuitbreaker/
pybreaker - https://pypi.org/project/pybreaker/
lasier - https://pypi.org/project/lasier/
breakers - https://pypi.org/project/breakers/
pybreaker - https://pypi.org/project/pybreaker/
python-circuit - https://pypi.org/project/python-circuit/
- Introduction
- Configuring the storage backend
- Monitoring Circuit States
- Changelog
- 1.0.3 - Released on 2023-07-29
- 1.0.2 - Released on 2023-05-10
- 1.0.1 - Released on 2022-05-28
- 1.0.0 - Released on 2022-02-27
- 0.7.2 - Released on 2022-01-18
- 0.7.1 - Released on 2022-01-16
- 0.7.0 (2022-01-04)
- 0.6.1 (2022-01-04)
- 0.6.0 (2022-01-04)
- 0.5.1 (2022-01-02)
- 0.5.0 (2022-01-01)
- 0.4.0 (2021-12-31)
- 0.3.0 (2021-12-30)
- 0.2.1 (2021-12-29)
- 0.2.0 (2021-12-29)
- 0.1.0 (2021-12-28)