Skip to content

Commit

Permalink
fix: 🐛 pass the timeout and ssl_context to the httpx (#105)
Browse files Browse the repository at this point in the history
Use the prepared client factory instead of direct call to httpx.
I have no explanation why it was the way it was.

RESOLVES #104
  • Loading branch information
zoido authored Nov 11, 2024
1 parent 8903b94 commit 106dbf2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/h2o_discovery/_internal/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class Client(_BaseClient):

def get_environment(self) -> model.Environment:
"""Returns the information about the environment."""
with httpx.Client(base_url=self._uri) as client:
with self._client() as client:
resp = _fetch(client, _ENVIRONMENT_ENDPOINT)
return model.Environment.from_json_dict(resp.json()["environment"])

def list_services(self) -> List[model.Service]:
"""Returns the list of all registered services."""
with httpx.Client(base_url=self._uri) as client:
with self._client() as client:
services: List[model.Service] = []

pages = _get_all_pages(client, _SERVICES_ENDPOINT)
Expand All @@ -55,7 +55,7 @@ def list_services(self) -> List[model.Service]:

def list_clients(self) -> List[model.Client]:
"""Returns the list of all registered clients."""
with httpx.Client(base_url=self._uri) as client:
with self._client() as client:
clients: List[model.Client] = []

pages = _get_all_pages(client, _CLIENTS_ENDPOINT)
Expand Down Expand Up @@ -103,13 +103,13 @@ class AsyncClient(_BaseClient):

async def get_environment(self) -> model.Environment:
"""Returns the information about the environment."""
async with httpx.AsyncClient(base_url=self._uri) as client:
async with self._client() as client:
resp = await _fetch_async(client, _ENVIRONMENT_ENDPOINT)
return model.Environment.from_json_dict(resp.json()["environment"])

async def list_services(self) -> List[model.Service]:
"""Returns the list of all registered services."""
async with httpx.AsyncClient(base_url=self._uri) as client:
async with self._client() as client:
services: List[model.Service] = []

pages = await _get_all_pages_async(client, _SERVICES_ENDPOINT)
Expand All @@ -121,7 +121,7 @@ async def list_services(self) -> List[model.Service]:

async def list_clients(self) -> List[model.Client]:
"""Returns the list of all registered clients."""
async with httpx.AsyncClient(base_url=self._uri) as client:
async with self._client() as client:
clients: List[model.Client] = []

pages = await _get_all_pages_async(client, _CLIENTS_ENDPOINT)
Expand Down

0 comments on commit 106dbf2

Please sign in to comment.