A resilient HTTP client wrapper with retry and circuit breaker patterns
Project description
HTTPWrapper
A modern, resilient HTTP client wrapper with advanced retry mechanisms and circuit breaker pattern implementation.
Features
- Advanced retry with exponential backoff and jitter
- Circuit breaker pattern for fault tolerance
- Configurable HTTP client settings
- Comprehensive logging and metrics
- Async/await support
- Type hints and modern Python practices
- Extensive test coverage
- Docker containerization support
Installation
pip install httpwrapper
Quick Start
from httpwrapper import HTTPClient
client = HTTPClient(
retry_config=RetryConfig(
max_attempts=3,
backoff_factor=0.3,
jitter=True
),
circuit_breaker_config=CircuitBreakerConfig(
failure_threshold=5,
recovery_timeout=60,
expected_exception=ConnectionError
)
)
response = client.get('https://api.example.com/data')
Architecture
Core Components
- HTTPClient: Main wrapper class extending base HTTP client
- RetryManager: Handles retry logic with backoff strategies
- CircuitBreaker: Implements circuit breaker state management
- MetricsCollector: Tracks request metrics and health
- Configuration: Centralized configuration management
Patterns Implemented
- Retry Pattern: Automatic retry with configurable backoff
- Circuit Breaker: Fail-fast protection for failing services
- Observer Pattern: Event-driven metric collection
- Factory Pattern: Configuration-driven object creation
Development Roadmap
Phase 1 - Core Implementation
- Project structure setup
- Base HTTP client implementation
- Basic retry mechanism
- Initial circuit breaker
- Configuration system
- Basic logging and metrics
Phase 2 - Advanced Features
- Exponential backoff with jitter
- Custom retry conditions
- Circuit breaker states (Closed, Open, Half-Open)
- Async support
- Connection pooling (implemented in async client)
- Response caching
Phase 3 - Production Readiness
- Comprehensive test suite (circuit breaker tests done)
- Performance benchmarks
- Docker containerization
- CI/CD pipeline
- Documentation
- Health checks
- Metrics dashboard
Phase 4 - Extensions
- Plugin system
- Multiple HTTP client backends
- Rate limiting
- Request/response interceptors
- Custom metrics exporters
Contributing
Please read CONTRIBUTING.md for details on our code of conduct and the process for submitting pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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 httpwrapper-0.1.1.tar.gz.
File metadata
- Download URL: httpwrapper-0.1.1.tar.gz
- Upload date:
- Size: 36.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a4bbb781cd64b2315999066a66111c0a1cebcc5337c48538a0104a155a881115
|
|
| MD5 |
60397c902ebfb0713be02fe695e1b253
|
|
| BLAKE2b-256 |
c664bacdda28065935c5679f52ee3881b3cc45c6f5272923c795191770799620
|
File details
Details for the file httpwrapper-0.1.1-py3-none-any.whl.
File metadata
- Download URL: httpwrapper-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93343beb35403b9c14816f32aa782ad54d96d80ff1f809a3b3d314c6f91d2298
|
|
| MD5 |
2f3a5da29da6cacf2313fdc3aec5e924
|
|
| BLAKE2b-256 |
bfef3bfbccf54df6383920ed58367fac9b0d446b51b06dac0f5dbfffd8b7efdc
|