Skip to content

Commit

Permalink
Merge branch 'main' into lp/drop-python-3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
zoido authored Jan 14, 2025
2 parents 23a0712 + 2a8f8ea commit 4d62f50
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/h2o_discovery/_internal/load.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import json
import os
import types
Expand Down Expand Up @@ -31,16 +32,27 @@ def load_discovery(cl: client.Client) -> model.Discovery:
async def load_discovery_async(cl: client.AsyncClient) -> model.Discovery:
"""Loads the discovery records from the Discovery Service."""
try:
environment = await cl.get_environment()
services = _get_service_map(await cl.list_services())
clients = _get_client_map(await cl.list_clients())
links = _get_link_map(await _list_links_async(cl))
return await _gather_discovery_async(cl)
except Exception as e:
_handle_specific_client_exceptions(e)
raise


async def _gather_discovery_async(cl: client.AsyncClient) -> model.Discovery:
environment_future = cl.get_environment()
services_future = cl.list_services()
clients_future = cl.list_clients()
links_future = _list_links_async(cl)

environment, services, clients, links = await asyncio.gather(
environment_future, services_future, clients_future, links_future
)

return model.Discovery(
environment=environment, services=services, clients=clients, links=links
environment=environment,
services=_get_service_map(services),
clients=_get_client_map(clients),
links=_get_link_map(links),
)


Expand Down

0 comments on commit 4d62f50

Please sign in to comment.