Skip to content

Commit cdff4c5

Browse files
authored
🐛Storage Worker does not need a RabbitMQ client (#7426)
1 parent 938c1da commit cdff4c5

File tree

2 files changed

+1
-16
lines changed

2 files changed

+1
-16
lines changed

services/storage/src/simcore_service_storage/core/application.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ def create_app(settings: ApplicationSettings) -> FastAPI: # noqa: C901
8484
setup_s3(app)
8585
setup_client_session(app)
8686

87-
setup_rabbitmq(app)
8887
if not settings.STORAGE_WORKER_MODE:
88+
setup_rabbitmq(app)
8989
setup_rpc_api_routes(app)
9090
setup_celery_client(app)
9191
setup_rest_api_long_running_tasks_for_uploads(app)

services/storage/src/simcore_service_storage/modules/rabbitmq.py

-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from fastapi import FastAPI
55
from servicelib.logging_utils import log_context
66
from servicelib.rabbitmq import (
7-
RabbitMQClient,
87
RabbitMQRPCClient,
98
wait_till_rabbitmq_responsive,
109
)
@@ -22,16 +21,12 @@ async def on_startup() -> None:
2221
logging.INFO,
2322
msg="Storage startup Rabbitmq",
2423
):
25-
app.state.rabbitmq_client = None
2624
rabbit_settings: RabbitSettings | None = app.state.settings.STORAGE_RABBITMQ
2725
if not rabbit_settings:
2826
raise ConfigurationError(
2927
msg="RabbitMQ client is de-activated in the settings"
3028
)
3129
await wait_till_rabbitmq_responsive(rabbit_settings.dsn)
32-
app.state.rabbitmq_client = RabbitMQClient(
33-
client_name="storage", settings=rabbit_settings
34-
)
3530
app.state.rabbitmq_rpc_server = await RabbitMQRPCClient.create(
3631
client_name="storage_rpc_server", settings=rabbit_settings
3732
)
@@ -42,23 +37,13 @@ async def on_shutdown() -> None:
4237
logging.INFO,
4338
msg="Storage shutdown Rabbitmq",
4439
):
45-
if app.state.rabbitmq_client:
46-
await app.state.rabbitmq_client.close()
4740
if app.state.rabbitmq_rpc_server:
4841
await app.state.rabbitmq_rpc_server.close()
4942

5043
app.add_event_handler("startup", on_startup)
5144
app.add_event_handler("shutdown", on_shutdown)
5245

5346

54-
def get_rabbitmq_client(app: FastAPI) -> RabbitMQClient:
55-
if not app.state.rabbitmq_client:
56-
raise ConfigurationError(
57-
msg="RabbitMQ client is not available. Please check the configuration."
58-
)
59-
return cast(RabbitMQClient, app.state.rabbitmq_client)
60-
61-
6247
def get_rabbitmq_rpc_server(app: FastAPI) -> RabbitMQRPCClient:
6348
assert app.state.rabbitmq_rpc_server # nosec
6449
return cast(RabbitMQRPCClient, app.state.rabbitmq_rpc_server)

0 commit comments

Comments
 (0)