Microframework de tolerância a falhas inspirado no SmallRye Fault Tolerance
Project description
PyFaultTolerance
Um microframework Python para tolerância a falhas assíncrona, inspirado no SmallRye Fault Tolerance.
Ideal para sistemas resilientes que utilizamasyncioouFastAPI.
✨ Funcionalidades
- ✅
@timeout_async: interrompe execução que exceder o tempo limite - 🔁
@retry_async: reexecuta em caso de falha, com controle de tentativas - 🧱
@bulkhead: limita concorrência simultânea (isolamento de chamadas) - 🔌
@fallback: define alternativa automática em caso de falha - 🚧
CircuitBreaker: previne chamadas para funções que falharam repetidamente - 📦 Exceções personalizadas com logs estruturados
📦 Instalação
Você pode instalar a biblioteca diretamente do PyPI:
pip install pyfaulttolerance
🚀 Uso
Timeout
from pyfaulttolerance.timeout import timeout, TimeoutException
@timeout(seconds=2)
def funcao_lenta():
# código que pode demorar
pass
Retry
from pyfaulttolerance.retry_async import retry_async
@retry_async(max_attempts=3, delay=1)
async def funcao_instavel():
# código que pode falhar
pass
Fallback
from pyfaulttolerance.fallback import fallback
async def alternativa():
return "valor alternativo"
@fallback(alternativa)
async def funcao_principal():
# código que pode falhar
pass
Bulkhead
from pyfaulttolerance.bulkhead import bulkhead
@bulkhead(max_concurrent_calls=2)
async def tarefa():
# código que deve ser limitado em concorrência
pass
Circuit Breaker
from pyfaulttolerance.circuit_breaker import CircuitBreaker
cb = CircuitBreaker(failure_threshold=3, recovery_timeout=10)
@cb
async def funcao():
# código que pode falhar
pass
📄 Licença
Este projeto está licenciado sob a Licença MIT. Consulte o arquivo LICENSE para mais detalhes.
Para mais informações, visite o repositório oficial: https://github.com/gomesrocha/pyfaulttolerance
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfaulttolerance-0.1.3.tar.gz.
File metadata
- Download URL: pyfaulttolerance-0.1.3.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c510d116dbc02fb3453bb8f22726f0d090454c3c7e09b472effcee2d6b4ce41b
|
|
| MD5 |
442f4430c314e0d5f26a3ffddce4253f
|
|
| BLAKE2b-256 |
3c0866613b84bab09e5e67892805468e10aa98324b32a75111ff4718b47b0065
|
Provenance
The following attestation bundles were made for pyfaulttolerance-0.1.3.tar.gz:
Publisher:
python-publish.yml on gomesrocha/pyfaulttolerance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfaulttolerance-0.1.3.tar.gz -
Subject digest:
c510d116dbc02fb3453bb8f22726f0d090454c3c7e09b472effcee2d6b4ce41b - Sigstore transparency entry: 212301546
- Sigstore integration time:
-
Permalink:
gomesrocha/pyfaulttolerance@0140f82edae0e23abb814ccd910a7e13971a4793 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/gomesrocha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0140f82edae0e23abb814ccd910a7e13971a4793 -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfaulttolerance-0.1.3-py3-none-any.whl.
File metadata
- Download URL: pyfaulttolerance-0.1.3-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38272bd8f93c4e0f357449a0c1fc57dc578d076710b7e9655f74a97f8b130a9f
|
|
| MD5 |
d15708893ae052bbf0b4feaa1c2313e9
|
|
| BLAKE2b-256 |
1dd43dbaef30ba3033f10f5ef58103fbdbebc35ea34e3d896374664197989723
|
Provenance
The following attestation bundles were made for pyfaulttolerance-0.1.3-py3-none-any.whl:
Publisher:
python-publish.yml on gomesrocha/pyfaulttolerance
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfaulttolerance-0.1.3-py3-none-any.whl -
Subject digest:
38272bd8f93c4e0f357449a0c1fc57dc578d076710b7e9655f74a97f8b130a9f - Sigstore transparency entry: 212301553
- Sigstore integration time:
-
Permalink:
gomesrocha/pyfaulttolerance@0140f82edae0e23abb814ccd910a7e13971a4793 -
Branch / Tag:
refs/tags/v0.1.4 - Owner: https://github.com/gomesrocha
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@0140f82edae0e23abb814ccd910a7e13971a4793 -
Trigger Event:
release
-
Statement type: