Skip to main content

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

PyPI Python

Shape: Federation sibling of mgf-common. The current mgf-common pin window is shown in this package's PyPI metadata — sourced from pyproject.toml at release time, so this README can't go stale. (Per v2.6 DOC-01 / project-shape taxonomy. PAPER-38.)

Sibling of mgf-common under the mgf.* namespace. Houses the typed httpx wrapper that previously lived under mgf.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

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.

Conformance: L2 per mgf-common/docs/standards/. Per-rule audit ledger: docs/inprogress/MGF_STANDARDS_CONFORMANCE.md. L2 means every federation MUST rule applies, evidenced by the tracker.

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

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

mgf_http-0.4.4.tar.gz (171.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mgf_http-0.4.4-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file mgf_http-0.4.4.tar.gz.

File metadata

  • Download URL: mgf_http-0.4.4.tar.gz
  • Upload date:
  • Size: 171.3 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

Hashes for mgf_http-0.4.4.tar.gz
Algorithm Hash digest
SHA256 60668edc7d3d7411b3c9ad564bb4ae90bd6c67c7cc6a692038a0253dee33236c
MD5 9813178a6f488ecb3a5c7bed1cff3c9f
BLAKE2b-256 42bb5421308cb91cf10ad66f5f59098209c90265a23ccdfe6c093daa49b4dad2

See more details on using hashes here.

File details

Details for the file mgf_http-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: mgf_http-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 26.1 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

Hashes for mgf_http-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 10b9bc2f5cc423ebd5897f16eaee5b028ab8b53d9476221f323e8b162081d507
MD5 03fce84f601050eee682c0bb831ba54c
BLAKE2b-256 a3a1e8c267196bc09820fddb9a4f962f6ddff4039d4403ff5584386515cd1cb1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page