Client
provide.foundation.transport.client
¶
TODO: Add module docstring.
Classes¶
UniversalClient
¶
Universal client that works with any transport via Hub registry.
The client uses a TransportCache that automatically evicts transports that exceed the failure threshold (default: 3 consecutive failures).
Functions¶
__aenter__
async
¶
__aexit__
async
¶
__aexit__(
exc_type: type[BaseException] | None,
exc_val: BaseException | None,
exc_tb: Any,
) -> None
Context manager exit - cleanup all transports.
Source code in provide/foundation/transport/client.py
delete
async
¶
get
async
¶
head
async
¶
options
async
¶
patch
async
¶
post
async
¶
put
async
¶
request
async
¶
request(
uri: str,
method: str | HTTPMethod = HTTPMethod.GET,
*,
headers: Headers | None = None,
params: Params | None = None,
body: Data = None,
timeout: float | None = None,
**kwargs: Any
) -> Response
Make a request using appropriate transport.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
Full URI to make request to |
required |
method
|
str | HTTPMethod
|
HTTP method or protocol-specific method |
GET
|
headers
|
Headers | None
|
Request headers |
None
|
params
|
Params | None
|
Query parameters |
None
|
body
|
Data
|
Request body (dict for JSON, str/bytes for raw) |
None
|
timeout
|
float | None
|
Request timeout override |
None
|
**kwargs
|
Any
|
Additional request metadata |
{}
|
Returns:
| Type | Description |
|---|---|
Response
|
Response from the transport |
Source code in provide/foundation/transport/client.py
reset_transport_cache
¶
Reset the transport cache.
Useful for testing or forcing reconnection after configuration changes.
stream
async
¶
stream(
uri: str,
method: str | HTTPMethod = HTTPMethod.GET,
**kwargs: Any
) -> AsyncIterator[bytes]
Stream data from URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
URI to stream from |
required |
method
|
str | HTTPMethod
|
HTTP method or protocol-specific method |
GET
|
**kwargs
|
Any
|
Additional request parameters |
{}
|
Yields:
| Type | Description |
|---|---|
AsyncIterator[bytes]
|
Chunks of response data |
Source code in provide/foundation/transport/client.py
Functions¶
delete
async
¶
get
async
¶
get_default_client
¶
Get or create the default client instance.
This function acts as the composition root for the default client, preserving backward compatibility for public convenience functions.
Source code in provide/foundation/transport/client.py
head
async
¶
options
async
¶
patch
async
¶
post
async
¶
put
async
¶
request
async
¶
Make a request using the default client.
stream
async
¶
Stream data using default client.