File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
packages/settings-library/src/settings_library
services/catalog/src/simcore_service_catalog/api/routes Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,14 @@ def dsn(self) -> str:
6464
6565 @cached_property
6666 def dsn_with_async_sqlalchemy (self ) -> str :
67- dsn = self .dsn .replace ("postgresql" , "postgresql+asyncpg" )
67+ dsn : str = PostgresDsn .build (
68+ scheme = "postgresql+asyncpg" ,
69+ user = self .POSTGRES_USER ,
70+ password = self .POSTGRES_PASSWORD .get_secret_value (),
71+ host = self .POSTGRES_HOST ,
72+ port = f"{ self .POSTGRES_PORT } " ,
73+ path = f"/{ self .POSTGRES_DB } " ,
74+ )
6875 return dsn
6976
7077 @cached_property
Original file line number Diff line number Diff line change 3939}
4040
4141DIRECTOR_CACHING_TTL = 5 * MINUTE
42+ LIST_SERVICES_CACHING_TTL = 30
4243
4344
4445def _prepare_service_details (
@@ -69,8 +70,19 @@ def _prepare_service_details(
6970 return validated_service
7071
7172
73+ def _build_cache_key (fct , * _ , ** kwargs ):
74+ return f"{ fct .__name__ } _{ kwargs ['user_id' ]} _{ kwargs ['x_simcore_products_name' ]} _{ kwargs ['details' ]} "
75+
76+
77+ # NOTE: this call is pretty expensive and can be called several times
78+ # (when e2e runs or by the webserver when listing projects) therefore
79+ # a cache is setup here
7280@router .get ("" , response_model = List [ServiceOut ], ** RESPONSE_MODEL_POLICY )
7381@cancellable_request
82+ @cached (
83+ ttl = LIST_SERVICES_CACHING_TTL ,
84+ key_builder = _build_cache_key ,
85+ )
7486async def list_services (
7587 request : Request , # pylint:disable=unused-argument
7688 user_id : PositiveInt ,
You can’t perform that action at this time.
0 commit comments