Skip to content

Commit d8cfe2e

Browse files
author
Andrei Neagu
committed
using correct namespaces to handle requests
1 parent 82861ce commit d8cfe2e

File tree

7 files changed

+56
-10
lines changed

7 files changed

+56
-10
lines changed

services/docker-compose.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -699,6 +699,8 @@ services:
699699
WEBSERVER_LOG_FORMAT_LOCAL_DEV_ENABLED: ${LOG_FORMAT_LOCAL_DEV_ENABLED}
700700
WEBSERVER_LOG_FILTER_MAPPING: ${LOG_FILTER_MAPPING}
701701

702+
LONG_RUNNING_TASKS_NAMESPACE_SUFFIX: webserver
703+
702704
# WEBSERVER_SERVER_HOST
703705

704706
WEBSERVER_HOST: ${WEBSERVER_HOST}
@@ -927,6 +929,8 @@ services:
927929
WEBSERVER_STATICWEB: "null"
928930
WEBSERVER_FUNCTIONS: ${WEBSERVER_FUNCTIONS} # needed for api-server
929931

932+
LONG_RUNNING_TASKS_NAMESPACE_SUFFIX: wb-api-server
933+
930934
networks: *webserver_networks
931935

932936
wb-db-event-listener:
@@ -936,6 +940,8 @@ services:
936940
environment:
937941
WEBSERVER_LOGLEVEL: ${WB_DB_EL_LOGLEVEL}
938942

943+
LONG_RUNNING_TASKS_NAMESPACE_SUFFIX: wb-db-event-listener
944+
939945
WEBSERVER_HOST: ${WEBSERVER_HOST}
940946
WEBSERVER_PORT: ${WEBSERVER_PORT}
941947

@@ -1032,6 +1038,8 @@ services:
10321038
LOG_FILTER_MAPPING: ${LOG_FILTER_MAPPING}
10331039
LOG_FORMAT_LOCAL_DEV_ENABLED: ${LOG_FORMAT_LOCAL_DEV_ENABLED}
10341040

1041+
LONG_RUNNING_TASKS_NAMESPACE_SUFFIX: wb-garbage-collector
1042+
10351043
# WEBSERVER_DB
10361044
POSTGRES_DB: ${POSTGRES_DB}
10371045
POSTGRES_ENDPOINT: ${POSTGRES_ENDPOINT}
@@ -1124,6 +1132,8 @@ services:
11241132
WEBSERVER_APP_FACTORY_NAME: WEBSERVER_AUTHZ_APP_FACTORY
11251133
WEBSERVER_LOGLEVEL: ${WB_AUTH_LOGLEVEL}
11261134

1135+
LONG_RUNNING_TASKS_NAMESPACE_SUFFIX: wb-auth
1136+
11271137
GUNICORN_CMD_ARGS: ${WEBSERVER_GUNICORN_CMD_ARGS}
11281138

11291139
# WEBSERVER_DB

services/web/server/src/simcore_service_webserver/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from .licenses.plugin import setup_licenses
4141
from .login.plugin import setup_login
4242
from .login_auth.plugin import setup_login_auth
43-
from .long_running_tasks import setup_long_running_tasks
43+
from .long_running_tasks.plugin import setup_long_running_tasks
4444
from .notifications.plugin import setup_notifications
4545
from .payments.plugin import setup_payments
4646
from .products.plugin import setup_products

services/web/server/src/simcore_service_webserver/application_settings.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
from .invitations.settings import InvitationsSettings
4141
from .licenses.settings import LicensesSettings
4242
from .login.settings import LoginSettings
43+
from .long_running_tasks.settings import LongRunningTasksSettings
4344
from .payments.settings import PaymentsSettings
4445
from .projects.settings import ProjectsSettings
4546
from .resource_manager.settings import ResourceManagerSettings
@@ -266,6 +267,14 @@ class ApplicationSettings(BaseApplicationSettings, MixinLoggingSettings):
266267
),
267268
]
268269

270+
WEBSERVER_LONG_RUNNING_TASKS: Annotated[
271+
LongRunningTasksSettings | None,
272+
Field(
273+
json_schema_extra={"auto_default_from_env": True},
274+
description="login plugin",
275+
),
276+
]
277+
269278
WEBSERVER_PAYMENTS: Annotated[
270279
PaymentsSettings | None,
271280
Field(

services/web/server/src/simcore_service_webserver/long_running_tasks/__init__.py

Whitespace-only changes.

services/web/server/src/simcore_service_webserver/long_running_tasks.py renamed to services/web/server/src/simcore_service_webserver/long_running_tasks/plugin.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
from servicelib.aiohttp.long_running_tasks.server import setup
1212
from servicelib.aiohttp.typing_extension import Handler
1313

14-
from . import rabbitmq_settings, redis
15-
from ._meta import API_VTAG
16-
from .login.decorators import login_required
17-
from .models import AuthenticatedRequestContext
18-
from .projects.plugin import register_projects_long_running_tasks
14+
from .. import rabbitmq_settings, redis
15+
from .._meta import API_VTAG
16+
from ..login.decorators import login_required
17+
from ..models import AuthenticatedRequestContext
18+
from ..projects.plugin import register_projects_long_running_tasks
19+
from . import settings as long_running_tasks_settings
1920

2021
_logger = logging.getLogger(__name__)
2122

@@ -45,14 +46,14 @@ def setup_long_running_tasks(app: web.Application) -> None:
4546
# register all long-running tasks from different modules
4647
register_projects_long_running_tasks(app)
4748

48-
namespace_suffix = "TODO" # TODO recover from settings
49+
settings = long_running_tasks_settings.get_plugin_settings(app)
4950

5051
setup(
5152
app,
5253
redis_settings=redis.get_plugin_settings(app),
5354
rabbit_settings=rabbitmq_settings.get_plugin_settings(app),
54-
redis_namespace=_get_namespace(namespace_suffix),
55-
rabbit_namespace=_get_namespace(namespace_suffix),
55+
redis_namespace=_get_namespace(settings.LONG_RUNNING_TASKS_NAMESPACE_SUFFIX),
56+
rabbit_namespace=_get_namespace(settings.LONG_RUNNING_TASKS_NAMESPACE_SUFFIX),
5657
router_prefix=f"/{API_VTAG}/tasks-legacy",
5758
handler_check_decorator=login_required,
5859
task_request_context_decorator=webserver_request_context_decorator,
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
from typing import Annotated
2+
3+
from aiohttp import web
4+
from pydantic import Field
5+
from settings_library.base import BaseCustomSettings
6+
7+
from ..constants import APP_SETTINGS_KEY
8+
9+
10+
class LongRunningTasksSettings(BaseCustomSettings):
11+
LONG_RUNNING_TASKS_NAMESPACE_SUFFIX: Annotated[
12+
str,
13+
Field(
14+
description=(
15+
"suffic to distinguis the service inside "
16+
"the long_running_tasks framework"
17+
),
18+
),
19+
]
20+
21+
22+
def get_plugin_settings(app: web.Application) -> LongRunningTasksSettings:
23+
settings = app[APP_SETTINGS_KEY].WEBSERVER_LONG_RUNNING_TASKS
24+
assert settings, "setup_settings not called?" # nosec
25+
assert isinstance(settings, LongRunningTasksSettings) # nosec
26+
return settings

services/web/server/src/simcore_service_webserver/tasks/_rest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
from .._meta import API_VTAG
3535
from ..constants import ASYNC_JOB_CLIENT_NAME
3636
from ..login.decorators import login_required
37-
from ..long_running_tasks import webserver_request_context_decorator
37+
from ..long_running_tasks.plugin import webserver_request_context_decorator
3838
from ..models import AuthenticatedRequestContext
3939
from ..rabbitmq import get_rabbitmq_rpc_client
4040
from ..security.decorators import permission_required

0 commit comments

Comments
 (0)