feat: add dexpace-sdk-http-httpx package · dexpace/python-sdk@c64a8cb · GitHub
Skip to content

Commit c64a8cb

Browse files
committed
feat: add dexpace-sdk-http-httpx package
1 parent 7589d32 commit c64a8cb

9 files changed

Lines changed: 1146 additions & 0 deletions

File tree

Lines changed: 166 additions & 0 deletions
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# dexpace-sdk-http-httpx
2+
3+
`httpx`-backed HTTP transports for
4+
[`dexpace-sdk-core`](https://pypi.org/project/dexpace-sdk-core/).
5+
6+
Ships two transports:
7+
8+
- `HttpxHttpClient` — sync, satisfies the `HttpClient` Protocol from `core`.
9+
- `AsyncHttpxHttpClient` — async, satisfies the `AsyncHttpClient` Protocol.
10+
11+
Unlike the stdlib reference transports (`UrllibHttpClient` /
12+
`AsyncioHttpClient`), `httpx` supports streaming uploads, per-phase
13+
timeouts (`connect` / `read` / `write` / `pool`), HTTP/2 (opt-in via
14+
`httpx`), and proxy configuration.
15+
16+
## Installation
17+
18+
```bash
19+
pip install dexpace-sdk-http-httpx
20+
```
21+
22+
This pulls in `dexpace-sdk-core` and `httpx` as required dependencies.
23+
24+
## Usage
25+
26+
```python
27+
from dexpace.sdk.core.http.common.url import Url
28+
from dexpace.sdk.core.http.context import DispatchContext
29+
from dexpace.sdk.core.http.request import Method, Request
30+
from dexpace.sdk.core.pipeline import Pipeline
31+
from dexpace.sdk.http.httpx import HttpxHttpClient
32+
33+
request = Request(
34+
method=Method.GET,
35+
url=Url.parse("https://api.example.com/v1/status"),
36+
)
37+
38+
with Pipeline(HttpxHttpClient(connect_timeout=5.0, read_timeout=30.0)) as pipeline:
39+
with pipeline.run(request, DispatchContext.noop()) as response:
40+
if response.is_success:
41+
payload = response.body.string()
42+
```
43+
44+
For async callers, use `AsyncHttpxHttpClient`:
45+
46+
```python
47+
from dexpace.sdk.http.httpx import AsyncHttpxHttpClient
48+
```
49+
50+
## Error mapping
51+
52+
`httpx` exceptions are mapped onto the `dexpace.sdk.core.errors`
53+
hierarchy:
54+
55+
| httpx exception | dexpace error |
56+
|---|---|
57+
| `httpx.ConnectError` | `ServiceRequestError` |
58+
| `httpx.ConnectTimeout` | `ServiceRequestTimeoutError` |
59+
| `httpx.ReadTimeout` | `ServiceResponseTimeoutError` |
60+
| `httpx.WriteTimeout` | `ServiceRequestTimeoutError` |
61+
| `httpx.PoolTimeout` | `ServiceRequestTimeoutError` |
62+
| `httpx.RequestError` (other) | `ServiceRequestError` |
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
[build-system]
2+
requires = ["hatchling"]
3+
build-backend = "hatchling.build"
4+
5+
[project]
6+
name = "dexpace-sdk-http-httpx"
7+
version = "0.1.0"
8+
description = "httpx-backed HTTP transports for dexpace-sdk-core."
9+
readme = "README.md"
10+
requires-python = ">=3.12"
11+
license = { file = "LICENSE.md" }
12+
authors = [{ name = "Omar Aljarrah", email = "o.mazari.om63@gmail.com" }]
13+
keywords = ["sdk", "http", "httpx"]
14+
classifiers = [
15+
"Development Status :: 3 - Alpha",
16+
"Intended Audience :: Developers",
17+
"License :: Other/Proprietary License",
18+
"Operating System :: OS Independent",
19+
"Programming Language :: Python :: 3",
20+
"Programming Language :: Python :: 3.12",
21+
"Programming Language :: Python :: 3.13",
22+
"Topic :: Software Development :: Libraries",
23+
]
24+
dependencies = [
25+
"dexpace-sdk-core>=0.1,<0.2",
26+
"httpx>=0.27,<0.29",
27+
]
28+
29+
[project.urls]
30+
Homepage = "https://github.com/dexpace/python-sdk"
31+
Repository = "https://github.com/dexpace/python-sdk"
32+
33+
[tool.hatch.build.targets.wheel]
34+
packages = ["src/dexpace/sdk/http/httpx"]
35+
sources = ["src"]
36+
37+
[tool.hatch.build.targets.sdist]
38+
include = ["src", "README.md"]
Lines changed: 8 additions & 0 deletions

0 commit comments

Comments
 (0)