-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🐛🎨♻️Director-v0: improve registry caching #6799
Merged
sanderegg
merged 29 commits into
ITISFoundation:master
from
sanderegg:dv-0/list-service-caching
Nov 22, 2024
Merged
Changes from 11 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
8eaeeb0
add pytest-benchmark
sanderegg 35de004
add external registry
sanderegg 8599207
add prefetching and generators
sanderegg 58de786
added tests with external registry
sanderegg 2603f5c
let's have more generators
sanderegg 8e36edc
skip test if no external registry set
sanderegg 20f50ec
unflake test
sanderegg 6c7234f
add httpx client session
sanderegg 2e6fd90
migrated to httpx
sanderegg f99ff9a
migrated to httpx and added retrials
sanderegg 181c80f
5 rounds
sanderegg b9dccf9
@pcrespov review: use fastapi.status
sanderegg 886d683
cleanup
sanderegg b7e3acf
ruff
sanderegg 5bcaea3
make sure the settings take care of the registry settings being correct
sanderegg 93da4df
cleanup
sanderegg cb37f16
missing refactoring
sanderegg 9ebba79
encoded true is needed here
sanderegg 83148bd
replace aioresponses with httpx
sanderegg 6aa1350
sonarcloud: use a specific name
sanderegg fdd0eba
remove confusion
sanderegg 220b215
ensure registry proxy uses internal registry URL
sanderegg b6aa263
ensure registry proxy uses api_url
sanderegg 0076aec
fix api_url to return protocol
sanderegg 7c7c431
fixes path
sanderegg 3e3d2f1
fix encoding
sanderegg a594613
fix required registry URL
sanderegg 1843d94
fix prefix
sanderegg cb215ae
missing env
sanderegg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registry accepts http/2?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well it does not reject it so why not use it?