Asynchronous HTTP client
Project description
Async Client Library
🚀 Project Overview
async-client-lib is a sophisticated Python asynchronous HTTP client library designed to provide efficient, flexible, and robust HTTP request handling. Leveraging modern Python packaging tools and best practices, this library offers a comprehensive solution for building resilient network communication interfaces.
🛠 Technology Stack
Core Technologies
- Language: Python 3.9+
- Async Framework:
aiohttp - Configuration Management:
pydantic - Retry Mechanism:
backoff
Development Tools
- Package Management: Poetry
- Testing: pytest, pytest-asyncio
- Code Quality:
- Formatting: Black
- Linting: Ruff
- Type Checking: mypy
📂 Project Structure
async-client-main/
├── async_client/
│ ├── __init__.py # Core library initialization
│ ├── _client.py # Base async HTTP client implementation
│ └── _exceptions.py # Custom exception handling
├── pyproject.toml # Project configuration and dependencies
├── README.md # Project documentation
└── LICENSE # MIT License
🔧 Key Components
1. BaseClient
- Provides core async HTTP request management
- Supports type-safe response parsing
- Configurable client settings
2. ClientConfig
- Manages client configuration parameters
- Supports SSL verification, timeouts, and host configuration
3. Error Handling
- Custom exception classes (
BaseError,ClientError) - Comprehensive error logging and reporting
🚀 Quick Start
Installation
pip install async-client-lib
# Or using Poetry
poetry add async-client-lib
Usage Example
from typing import List, Dict
from pydantic import BaseModel
from async_client import BaseClient, ClientConfig
class SlideShow(BaseModel):
title: str
author: str
date: str
slides: List[Dict]
class SlideShowResponse(BaseModel):
slideshow: SlideShow
class HttpBinClient(BaseClient):
async def get_json(self) -> SlideShow:
url = self.get_path("json")
resp = await self._perform_request("GET", url)
data = self.load_schema(resp.body, SlideShowResponse)
return data.slideshow
async def main():
config = ClientConfig(
HOST="https://httpbin.org",
SSL_VERIFY=True,
CLIENT_TIMEOUT=30,
)
async with HttpBinClient(config) as client:
slideshow = await client.get_json()
print(slideshow)
if __name__ == "__main__":
import asyncio
asyncio.run(main())
🛡 Development
Setup
# Install dependencies
poetry install
# Run tests
poetry run pytest
# Code quality checks
poetry run black .
poetry run ruff check .
📋 Configuration Options
| Parameter | Description | Default |
|---|---|---|
HOST |
Base URL for requests | Required |
SSL_VERIFY |
SSL certificate verification | True |
CLIENT_TIMEOUT |
Request timeout duration | 30 |
📄 License
MIT License
📞 Contact
Aleksey Matyunin
- Email: matyunin.as@mail.ru
🔖 Version
Current version: 0.1.8
Note: Always refer to the latest documentation and release notes for the most up-to-date information.
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 async_client_lib-0.1.9.tar.gz.
File metadata
- Download URL: async_client_lib-0.1.9.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.1 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e485557e7a3b4e7f653c9eb3732ce6b8f9f2f2125ede6e0e4ba1fe887b906e1c
|
|
| MD5 |
53a09534c444ea83f71b8c551110e63d
|
|
| BLAKE2b-256 |
0c6265cc6efe2913a6dd34f316bdfaad271d5a074a5a79c54e72950f38b0c0d9
|
File details
Details for the file async_client_lib-0.1.9-py3-none-any.whl.
File metadata
- Download URL: async_client_lib-0.1.9-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.1 CPython/3.12.1 Linux/6.8.0-1021-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b84f7b1fe70d8c2aba646cf6ba73ef4b34917390407a46e39fd12ece72e45255
|
|
| MD5 |
876f72a76a5f09435f33ce3ae88c1ac5
|
|
| BLAKE2b-256 |
b76fc71c48d8cbe0b7b35d6d00246172daf5f5aa107c1befe9bedf3d80883cb2
|