Add support for RabbitMQ connection string to the Autosync service

Signed-off-by: Fred Heincke <fred.heinecke@yahoo.com>
This commit is contained in:
Fred Heincke 2025-04-25 06:35:32 +00:00 committed by Zoe Roux
parent a39baa1b50
commit 02c2a2db52
2 changed files with 13 additions and 0 deletions

12
autosync/.env.example Normal file
View File

@ -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

View File

@ -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"),