From 02c2a2db52ed1e0ab799f9bc96623d8fd70e0445 Mon Sep 17 00:00:00 2001 From: Fred Heincke Date: Fri, 25 Apr 2025 06:35:32 +0000 Subject: [PATCH] Add support for RabbitMQ connection string to the Autosync service Signed-off-by: Fred Heincke --- autosync/.env.example | 12 ++++++++++++ autosync/autosync/consumer.py | 1 + 2 files changed, 13 insertions(+) create mode 100644 autosync/.env.example diff --git a/autosync/.env.example b/autosync/.env.example new file mode 100644 index 00000000..90b614e7 --- /dev/null +++ b/autosync/.env.example @@ -0,0 +1,12 @@ +# vi: ft=sh +# shellcheck disable=SC2034 + +# RabbitMQ settings +# URL examples: https://docs.aio-pika.com/#url-examples +# This uses AIORMQ (https://github.com/mosquito/aiormq/) under the hood, and supports whatever the library supports. +# RABBITMQ_URL=ampqs://user:password@rabbitmq-server:1234/vhost?capath=/path/to/cacert.pem&certfile=/path/to/cert.pem&keyfile=/path/to/key.pem +# These values are ignored when the RABBITMQ_URL is set +RABBITMQ_HOST=rabbitmq +RABBITMQ_PORT=5672 +RABBITMQ_USER=guest +RABBITMQ_PASSWORD=guest diff --git a/autosync/autosync/consumer.py b/autosync/autosync/consumer.py index f530309d..b2911eca 100644 --- a/autosync/autosync/consumer.py +++ b/autosync/autosync/consumer.py @@ -17,6 +17,7 @@ class Consumer: async def __aenter__(self): self._con = await connect_robust( + os.environ.get("RABBITMQ_URL"), host=os.environ.get("RABBITMQ_HOST", "rabbitmq"), port=int(os.environ.get("RABBITMQ_PORT", "5672")), login=os.environ.get("RABBITMQ_DEFAULT_USER", "guest"),