Repository navigation
Add optional httpx2 support to the ingress client - #248
maksimzayats wants to merge 4 commits into
Conversation
(cherry picked from commit fcb9991)
Accept structural HTTP clients without importing either HTTP package. Keep httpx as the factory default and add explicit httpx2 selection with a separate optional extra. Restore the harness and existing extras to their upstream behavior. Cover backend selection, request and error behavior, imports, and types. Refs restatedev#247
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
|
Hi @slinkydeveloper and @igalshilman. Could you please review this PR when you have time? It keeps httpx as the default and adds optional httpx2 support. Thank you. |
|
Hi @slinkydeveloper and @igalshilman. Could you please review this PR when you have time? It keeps httpx as the default and adds optional httpx2 support. Thank you. |
|
Hi @slinkydeveloper and @igalshilman. Could you please review this PR when you have time? It keeps httpx as the default and adds optional httpx2 support. Thank you. |
|
Hi @slinkydeveloper and @igalshilman. Could you please review this PR when you have time? It keeps httpx as the default and adds optional httpx2 support. Thank you. |
|
fixed in main, thank you for reporting this! |
Summary
Fixes #247. Allow
Clientto use a compatible async HTTP client without requiring httpx at import time.Add
HttpClientandHttpResponseprotocols. Export them fromrestate.client_typesandrestate. Import the selected HTTP package inside the factory. If it is missing, report the matching SDK install command. Reject invalid backend values. Pass through import failures inside an installed package.Keep
client = ["httpx[http2]"]. Add the separateclient-httpx2 = ["httpx2[http2]>=2.12,<3"]extra. Add no base dependency.This builds on Arthur Depasse's PR #231. The first commit retains his author identity and source commit reference. Later commits adapt his work to this scope. Please preserve his authored commit when merging.
Evidence
Clientfrom current upstream main fails when httpx is blocked.After: the import passes with both HTTP packages blocked. Clean wheels also import with neither package installed.
just sync,just buildandjust verifypass on Python 3.10 through 3.14. Each version passes Ruff, Mypy, Pyright and all 67 tests.Local Python checks use macOS arm64. Conformance uses Linux arm64 containers. GitHub Test and Integration workflows still need maintainer approval. The CLA check now passes.
Compatibility and scope
The three existing factory arguments keep their positional meaning. The default remains httpx. The new
backendargument is keyword-only. There is no fallback. Both paths keep HTTP/2, headers, codec forwarding and async cleanup.Client.clientremains the supplied object. Requests and return values stay the same. HTTP status errors keep the sameHttpError.status_code,.messageand.bodyvalues from #152. Transport errors keep each client's own exception types.The harness, its extra and downstream integrations are unchanged. Python 3.10 remains supported. The lock file records the new extra and its required dependencies.
Open question
Should httpx be deprecated in a future change? This PR supports both packages and adds no deprecation warning.
Merge Danger
Door: Two-way. Reverting this change needs no data migration.
Blast Radius: Ingress. Existing httpx calls and the existing client extra keep their behavior.