-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛🎨♻️Director-v0: improve registry caching (#6799)
- Loading branch information
Showing
17 changed files
with
410 additions
and
340 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
aiocache | ||
aiodocker | ||
fastapi[all] | ||
httpx | ||
httpx[http2] | ||
prometheus-client | ||
pydantic | ||
tenacity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ faker | |
jsonref | ||
pytest | ||
pytest-asyncio | ||
pytest-benchmark | ||
pytest-cov | ||
pytest-docker | ||
pytest-instafail | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 6 additions & 25 deletions
31
services/director/src/simcore_service_director/client_session.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,22 @@ | ||
from aiohttp import ClientSession, ClientTimeout | ||
from common_library.json_serialization import json_dumps | ||
import httpx | ||
from fastapi import FastAPI | ||
from servicelib.utils import ( | ||
get_http_client_request_aiohttp_connect_timeout, | ||
get_http_client_request_aiohttp_sock_connect_timeout, | ||
get_http_client_request_total_timeout, | ||
) | ||
|
||
|
||
def setup_client_session(app: FastAPI) -> None: | ||
async def on_startup() -> None: | ||
# SEE https://github.com/ITISFoundation/osparc-simcore/issues/4628 | ||
|
||
# ANE: it is important to have fast connection handshakes | ||
# also requests should be as fast as possible | ||
# some services are not that fast to reply | ||
timeout_settings = ClientTimeout( | ||
total=get_http_client_request_total_timeout(), | ||
connect=get_http_client_request_aiohttp_connect_timeout(), | ||
sock_connect=get_http_client_request_aiohttp_sock_connect_timeout(), | ||
) | ||
session = ClientSession( | ||
timeout=timeout_settings, | ||
json_serialize=json_dumps, | ||
) | ||
session = httpx.AsyncClient(transport=httpx.AsyncHTTPTransport(http2=True)) | ||
app.state.aiohttp_client_session = session | ||
|
||
async def on_shutdown() -> None: | ||
session = app.state.aiohttp_client_session | ||
assert isinstance(session, ClientSession) # nosec | ||
await session.close() | ||
assert isinstance(session, httpx.AsyncClient) # nosec | ||
await session.aclose() | ||
|
||
app.add_event_handler("startup", on_startup) | ||
app.add_event_handler("shutdown", on_shutdown) | ||
|
||
|
||
def get_client_session(app: FastAPI) -> ClientSession: | ||
def get_client_session(app: FastAPI) -> httpx.AsyncClient: | ||
session = app.state.aiohttp_client_session | ||
assert isinstance(session, ClientSession) # nosec | ||
assert isinstance(session, httpx.AsyncClient) # nosec | ||
return session |
5 changes: 0 additions & 5 deletions
5
services/director/src/simcore_service_director/core/errors.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.