peyk.transport.session¶
A single, reused aiohttp.ClientSession behind a generic request() call.
Performance choices here (tuned TCPConnector, orjson for JSON) are generic, documented aiohttp/Python practices — not copied from any specific library’s source. See docs/decisions.md for the reasoning behind the specific connector values and for the “techniques, not code” note.
Classes
|
Wraps one reused aiohttp.ClientSession backed by a tuned connector. |
|
The result of a successful (2xx) transport-level request. |
- class peyk.transport.session.TransportResponse(status: int, json: object | None, body: bytes, headers: Mapping[str, str])[source]¶
Bases:
objectThe result of a successful (2xx) transport-level request.
- Variables:
status (int) – HTTP status code.
json (object | None) – Parsed body via orjson, if the response’s Content-Type indicated JSON and the body parsed successfully. None otherwise.
body (bytes) – Raw response body bytes, always populated.
headers (Mapping[str, str]) – Response headers as a plain mapping.
- status: int¶
- json: object | None¶
- body: bytes¶
- headers: Mapping[str, str]¶
- class peyk.transport.session.Session(*, limit: int = DEFAULT_LIMIT, limit_per_host: int = DEFAULT_LIMIT_PER_HOST, keepalive_timeout: float = DEFAULT_KEEPALIVE_TIMEOUT, ttl_dns_cache: int = DEFAULT_TTL_DNS_CACHE, logger: TransportLogger | None = None)[source]¶
Bases:
objectWraps one reused aiohttp.ClientSession backed by a tuned connector.
- property connector: BaseConnector¶
The underlying connector, exposed so reuse can be asserted in tests.
- Returns:
The operation result (
aiohttp.BaseConnector).
- async request(method: str, url: str, *, params: Mapping[str, object] | None = None, json_body: object | None = None, data: object | None = None, files: Mapping[str, FilePayload] | None = None, timeout: float | None = None) TransportResponse[source]¶
Performs the request operation for the transport client.
- Parameters:
method – Value used by this operation.
url – Target URL.
params – Value used by this operation.
json_body – Value used by this operation.
data – Value used by this operation.
files – Value used by this operation.
timeout – Maximum time to wait for the operation.
- Returns:
Result produced by the transport operation.