1+ """HTTP transport layer for Bubble Data API requests."""
2+
13import types
24import typing
35
46import httpx
57
6- DEFAULT_USER_AGENT = "bubble-data-api-client"
8+ from bubble_data_api_client . pool import get_client
79
810
9- def httpx_client_factory (
10- base_url : str ,
11- api_key : str ,
12- ) -> httpx .AsyncClient :
13- return httpx .AsyncClient (
14- base_url = base_url ,
15- headers = {
16- "Authorization" : f"Bearer { api_key } " ,
17- "User-Agent" : DEFAULT_USER_AGENT ,
18- },
19- transport = httpx .AsyncHTTPTransport (retries = 3 ),
20- timeout = httpx .Timeout (60.0 ),
21- )
11+ class Transport :
12+ """Async context manager for HTTP operations.
2213
14+ Responsibilities:
15+ - Obtains a pooled httpx client on entry
16+ - Provides HTTP verb methods (get, post, patch, put, delete)
17+ - Raises on non-2xx responses
2318
24- class Transport :
25- """
26- Transport layer focuses on HTTP.
27- - authentication, headers, retries, timeouts: configured via httpx_client_factory
28- - connection lifecycle: managed by pool module
29- - HTTP verb methods: get, post, patch, put, delete
30- - error handling: raise_for_status on responses
19+ HTTP client configuration (headers, retries, timeouts) is handled by
20+ the http_client module. Connection pooling is handled by the pool module.
3121 """
3222
3323 _http : httpx .AsyncClient
@@ -36,9 +26,6 @@ def __init__(self) -> None:
3626 pass
3727
3828 async def __aenter__ (self ) -> typing .Self :
39- # deferred import to avoid circular dependency: pool imports transport
40- from bubble_data_api_client .pool import get_client
41-
4229 self ._http = get_client ()
4330 return self
4431
0 commit comments