Resilient decorators that return Result types instead of throwing exceptions
Project description
resilient-result
Policy-based resilience with beautiful Result types.
from resilient_result import resilient, Retry, Backoff
@resilient(retry=Retry.api(), backoff=Backoff.exp())
async def call_api(url: str) -> str:
return await http.get(url)
result = await call_api("https://api.example.com")
if result.success:
print(result.data) # Clean success
else:
print(f"Failed: {result.error}") # No exceptions thrown
Why resilient-result? Policy objects over primitives, Result types over exceptions, zero ceremony.
Installation
pip install resilient-result
Core Features
Policy-Based Configuration
from resilient_result import resilient, Retry, Circuit, Backoff
# Beautiful presets
@resilient(retry=Retry.api()) # API defaults
@resilient(retry=Retry.db(), backoff=Backoff.linear()) # Database operations
# Custom configuration
@resilient(retry=Retry(attempts=5, timeout=10), circuit=Circuit.fast())
async def critical_operation():
return await external_service()
Result Types Over Exceptions
from resilient_result import Result, Ok, Err
# Clean error handling - no try/catch needed
result = await call_api("https://api.example.com")
if result.success:
process(result.data)
else:
log_error(result.error)
Built-in Patterns
@resilient.network() # Smart retry for network errors
@resilient.parsing() # JSON parsing with recovery
@resilient.circuit() # Circuit breaker protection
@resilient.rate_limit() # Token bucket rate limiting
License
MIT - Build amazing resilient systems! 🚀
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
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 resilient_result-0.3.0.tar.gz.
File metadata
- Download URL: resilient_result-0.3.0.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.10 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46bb35fb0875e328925497f20e788b0abf657195be1b0cf3672126a93489b5ca
|
|
| MD5 |
68023dd32d35ec58311d3accc405757e
|
|
| BLAKE2b-256 |
54cdf2b5147f85d79a86ad326a4d470650641dc82cb0d8c80be83d542789a201
|
File details
Details for the file resilient_result-0.3.0-py3-none-any.whl.
File metadata
- Download URL: resilient_result-0.3.0-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.12.10 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c464a3d8669c56885cd99487abf3e5c540ab7cd97e632b94b93aa2f9706d632b
|
|
| MD5 |
fdac03782afa9beac6ac178ff2abb65d
|
|
| BLAKE2b-256 |
57bfe92d636936c05ce9ecdbf77bae73b4fddb2d1b2777c360f2bff23eb2b745
|