Async HTTP client for mgf-common consumers — typed httpx wrapper with retries, timeouts, header redaction, OTel-aware logging. Sibling of mgf-common under the mgf.* namespace.
Project description
mgf-http — typed async HTTP client for mgf-common consumers
Sibling of
mgf-commonunder themgf.*namespace. Houses the typed httpx wrapper that previously lived undermgf.common.http.*— extracted at mgf-common v0.29 / mgf-http v0.1 per the federation split plan.
What this provides
| Submodule | What |
|---|---|
mgf.http |
AsyncHttpClient — thin wrapper over httpx.AsyncClient with retries, timeouts, header redaction, OTel-aware logging, typed error translation. RetryPolicy — exponential backoff with jitter; per-request override. |
mgf.http.exceptions |
HttpTransportError(OperationError) — transport-layer failure (timeout, connect-refused, network unreachable). Renamed from HttpClientError at the v0.29 cutover to disambiguate from mgf.common.exceptions.HttpClientError (the HTTP-01 4xx-class hierarchy parent, which stays in mgf-common). |
Install
pip install mgf-http
# Or with the test extra (respx for mocking httpx in your tests):
pip install 'mgf-http[test]'
Pulls in mgf-common and httpx automatically.
Quick start
import asyncio
from mgf.http import AsyncHttpClient, RetryPolicy
async def main() -> None:
async with AsyncHttpClient(
base_url="https://api.example.com",
timeout=10.0,
retry=RetryPolicy(max_attempts=3),
) as http:
response = await http.get("/users", params={"page": 1})
response.raise_for_status()
users = response.json()
asyncio.run(main())
The client auto-derives a User-Agent of the shape
<app>/<ver> mgf-http/<libver> from mgf.common.app_name() /
mgf.common.app_version() (call mgf.common.bootstrap() at startup
for accurate identity). Authorization / Cookie / X-Api-Key family
headers are redacted in logs and OTel spans automatically.
Documentation
docs/recipes/http.md— full HTTP-client walkthrough.docs/cutover/v0.1.0.md— maiden voyage migration story (the v0.29 split, including theHttpClientError→HttpTransportErrorrename).PUBLIC_API.md— full public surface contract.CHANGELOG.md— release history.
For the federation-wide engineering standards (DESIGN_PRINCIPLES,
ERROR_HANDLING, SECURITY, etc.) see
mgf-common/docs/standards/.
This sibling inherits them by reference; the standards
source-of-truth lives in mgf-common.
Status
🚧 Experimental — every public name is experimental per AP-09.
Promotion to stable happens release-by-release as consumer feedback
in mgf-common/FEEDBACK.md
converges. The 0.x window applies. Pin tightly:
mgf-http = ">=0.X.0,<0.Y".
Cross-references
- Filing process for sharp edges: open an entry on
mgf-common/FEEDBACK.mdwith[mgf-http]prefix, OR file directly on this repo's Issues → maintainer mirrors into the canonical FEEDBACK.md. - Federation pattern:
mgf-common/docs/design/federation.md. - The split that created this sibling:
mgf-common/docs/release/federation_roadmap.md.
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 mgf_http-0.1.0.tar.gz.
File metadata
- Download URL: mgf_http-0.1.0.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
819e89ec4d65289dec4ab6b76609c8c7f3b149c1e3a0181fb67777696d9124e9
|
|
| MD5 |
9fe19a77f6f0b89eb0db24267241a673
|
|
| BLAKE2b-256 |
13eee328e7ca069579b4438b93f3460efa872f4fde94f643e5597ff07f953543
|
File details
Details for the file mgf_http-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mgf_http-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.8 {"installer":{"name":"uv","version":"0.10.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2810418229929bc4d2d83cb4be2af13d9b4bb3bfc36b20fdc25f944c91d2bc6f
|
|
| MD5 |
67721b05483bc5fc507c5356c6aa83a4
|
|
| BLAKE2b-256 |
67d49de06ec4813196ab426755a7be8fff2d9b6d4e9cc7d54fc53c8a75f99ad7
|