Skip to content

Commit d33dc55

Browse files
Enable http2 for sync client (#330)
1 parent 279979a commit d33dc55

File tree

6 files changed

+1270
-22
lines changed

6 files changed

+1270
-22
lines changed

poetry.lock

Lines changed: 94 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ python-dateutil = "^2.8.2"
3737
pydantic = "2.11.7"
3838
aiohttp = "3.12.15"
3939
aiohttp-retry = "2.9.1"
40+
httpx = "^0.28.1"
4041

4142
[tool.poetry.group.dev.dependencies]
4243
pylint = ">=2.17.5"

src/conductor/client/adapters/api_client_adapter.py

Lines changed: 73 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,42 +2,96 @@
22

33
from conductor.client.codegen.api_client import ApiClient
44
from conductor.client.configuration.configuration import Configuration
5+
from conductor.client.adapters.rest_adapter import RESTClientObjectAdapter
56

67
from conductor.client.codegen.rest import AuthorizationException, ApiException
78

89
logger = logging.getLogger(Configuration.get_logging_formatted_name(__name__))
910

11+
1012
class ApiClientAdapter(ApiClient):
13+
def __init__(
14+
self, configuration=None, header_name=None, header_value=None, cookie=None
15+
):
16+
"""Initialize the API client adapter with httpx-based REST client."""
17+
super().__init__(configuration, header_name, header_value, cookie)
18+
self.rest_client = RESTClientObjectAdapter(
19+
connection=configuration.http_connection if configuration else None
20+
)
21+
1122
def __call_api(
12-
self, resource_path, method, path_params=None,
13-
query_params=None, header_params=None, body=None, post_params=None,
14-
files=None, response_type=None, auth_settings=None,
15-
_return_http_data_only=None, collection_formats=None,
16-
_preload_content=True, _request_timeout=None):
23+
self,
24+
resource_path,
25+
method,
26+
path_params=None,
27+
query_params=None,
28+
header_params=None,
29+
body=None,
30+
post_params=None,
31+
files=None,
32+
response_type=None,
33+
auth_settings=None,
34+
_return_http_data_only=None,
35+
collection_formats=None,
36+
_preload_content=True,
37+
_request_timeout=None,
38+
):
1739
try:
18-
logger.debug("HTTP request method: %s; resource_path: %s; header_params: %s", method, resource_path, header_params)
40+
logger.debug(
41+
"HTTP request method: %s; resource_path: %s; header_params: %s",
42+
method,
43+
resource_path,
44+
header_params,
45+
)
1946
return self.__call_api_no_retry(
20-
resource_path=resource_path, method=method, path_params=path_params,
21-
query_params=query_params, header_params=header_params, body=body, post_params=post_params,
22-
files=files, response_type=response_type, auth_settings=auth_settings,
23-
_return_http_data_only=_return_http_data_only, collection_formats=collection_formats,
24-
_preload_content=_preload_content, _request_timeout=_request_timeout
47+
resource_path=resource_path,
48+
method=method,
49+
path_params=path_params,
50+
query_params=query_params,
51+
header_params=header_params,
52+
body=body,
53+
post_params=post_params,
54+
files=files,
55+
response_type=response_type,
56+
auth_settings=auth_settings,
57+
_return_http_data_only=_return_http_data_only,
58+
collection_formats=collection_formats,
59+
_preload_content=_preload_content,
60+
_request_timeout=_request_timeout,
2561
)
2662
except AuthorizationException as ae:
2763
if ae.token_expired or ae.invalid_token:
2864
token_status = "expired" if ae.token_expired else "invalid"
29-
logger.warning("HTTP response from: %s; token_status: %s; status code: 401 - obtaining new token", resource_path, token_status)
65+
logger.warning(
66+
"HTTP response from: %s; token_status: %s; status code: 401 - obtaining new token",
67+
resource_path,
68+
token_status,
69+
)
3070
# if the token has expired or is invalid, lets refresh the token
3171
self.__force_refresh_auth_token()
3272
# and now retry the same request
3373
return self.__call_api_no_retry(
34-
resource_path=resource_path, method=method, path_params=path_params,
35-
query_params=query_params, header_params=header_params, body=body, post_params=post_params,
36-
files=files, response_type=response_type, auth_settings=auth_settings,
37-
_return_http_data_only=_return_http_data_only, collection_formats=collection_formats,
38-
_preload_content=_preload_content, _request_timeout=_request_timeout
74+
resource_path=resource_path,
75+
method=method,
76+
path_params=path_params,
77+
query_params=query_params,
78+
header_params=header_params,
79+
body=body,
80+
post_params=post_params,
81+
files=files,
82+
response_type=response_type,
83+
auth_settings=auth_settings,
84+
_return_http_data_only=_return_http_data_only,
85+
collection_formats=collection_formats,
86+
_preload_content=_preload_content,
87+
_request_timeout=_request_timeout,
3988
)
4089
raise ae
4190
except ApiException as e:
42-
logger.error("HTTP request failed url: %s status: %s; reason: %s", resource_path, e.status, e.reason)
43-
raise e
91+
logger.error(
92+
"HTTP request failed url: %s status: %s; reason: %s",
93+
resource_path,
94+
e.status,
95+
e.reason,
96+
)
97+
raise e

0 commit comments

Comments
 (0)