feat(async): add HTTPClientConfig for tuning the async transport (closes #170)#171
Open
be-ant wants to merge 1 commit into
Open
feat(async): add HTTPClientConfig for tuning the async transport (closes #170)#171be-ant wants to merge 1 commit into
be-ant wants to merge 1 commit into
Conversation
Closes btoron#170 Introduces a library-neutral HTTPClientConfig (scalar fields only — int/float/bool/str) accepted by AsyncOFSC. The translation to httpx.Limits / httpx.Timeout / httpx.AsyncHTTPTransport happens entirely inside AsyncOFSC, so the public surface survives a future transport library swap. Exposed knobs (all optional; defaults preserve current behavior): max_concurrency, timeout, max_retries, proxy, verify_ssl, http2, follow_redirects, trust_env.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
HTTPClientConfig— a Pydantic model with scalar fields only — that lets users tune the async transport without leakinghttpxtypes into the public API.AsyncOFSC(..., http_config=...); defaults preserve today's behavior (HTTP/2 on, default pool/timeout, no retries).max_concurrency, which translates tohttpx.Limits(max_connections=N, max_keepalive_connections=N)— same semantics as aiohttp'sTCPConnector(limit=N), so the abstraction survives a transport library swap.timeout,max_retries(transport-level),proxy,verify_ssl,http2,follow_redirects,trust_env.httpx.AsyncClient.Closes #170.
Why library-neutral
HTTPClientConfigdeliberately exposes onlyint/float/bool/str. Thehttpx.Limits/httpx.Timeout/httpx.AsyncHTTPTransporttranslation lives entirely insideAsyncOFSC._build_client_kwargs. If the project ever swaps httpx for another async HTTP client, the public surface here stays the same.Example
Backward compatibility
http_configdefaults toNone. When unset, the constructor builds the client exactly as before. No existing call sites need to change.Test plan
uv run pytest tests/async/test_async_http_config.py -v— 17 new tests passuv run pytest tests/async/test_async_ofsc.py -v— existing async client tests still passuv run pytest -m "not uses_real_data and not uses_local_data and not integration"— 443 passed, 8 skippeduv run ruff checkclean on changed filesuv run ruff format --checkclean on changed filesuv run pytestwith live credentials to confirm no regression in credentialed tests