From bc9d69c6e27453dc0c4b050dfd7af8849a822c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Sat, 7 Nov 2026 12:34:22 +0300 Subject: [PATCH] feat(infra): lab5 add rabbitmq service and outbox config --- backend/internal/config/config.go | 16 ++++++++++++++++ compose.yaml | 28 +++++++++++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/backend/internal/config/config.go b/backend/internal/config/config.go index 6419db3..66d0232 100644 --- a/backend/internal/config/config.go +++ b/backend/internal/config/config.go @@ -31,6 +31,9 @@ type Config struct { ReconcilerEnabled bool ReconcilerInterval time.Duration ReconcilerGracePeriod time.Duration + + RabbitMQURL string + OutboxInterval time.Duration } func Load() (*Config, error) { @@ -127,6 +130,16 @@ func Load() (*Config, error) { return nil, fmt.Errorf("RECONCILER_GRACE_SECONDS должен быть положительным") } + rabbitURL, err := readSecretOptional("RABBITMQ_URL_FILE", "RABBITMQ_URL") + if err != nil { + return nil, fmt.Errorf("rabbitmq url: %w", err) + } + + outboxMs, err := readInt("OUTBOX_INTERVAL_MS", 1000) + if err != nil { + return nil, fmt.Errorf("OUTBOX_INTERVAL_MS: %w", err) + } + return &Config{ Host: getenv("APP_HOST", "0.0.0.0"), Port: getenv("APP_PORT", "8080"), @@ -150,6 +163,9 @@ func Load() (*Config, error) { ReconcilerEnabled: reconcilerEnabled, ReconcilerInterval: time.Duration(reconcilerIntervalSec) * time.Second, ReconcilerGracePeriod: time.Duration(reconcilerGraceSec) * time.Second, + + RabbitMQURL: rabbitURL, + OutboxInterval: time.Duration(outboxMs) * time.Millisecond, }, nil } diff --git a/compose.yaml b/compose.yaml index bda9b13..511ea1d 100644 --- a/compose.yaml +++ b/compose.yaml @@ -64,6 +64,30 @@ services: networks: - internal +rabbitmq: + image: rabbitmq:3.13-management-alpine + restart: unless-stopped + environment: + RABBITMQ_DEFAULT_USER: "messenger" + RABBITMQ_DEFAULT_PASS_FILE: /run/secrets/rabbitmq_password + secrets: + - rabbitmq_password + volumes: + - rabbitmq_data:/var/lib/rabbitmq + ports: + - "15672:15672" + healthcheck: + test: ["CMD", "rabbitmq-diagnostics", "-q", "ping"] + interval: 5s + timeout: 3s + retries: 10 + deploy: + resources: + limits: + memory: 256M + networks: + - internal + minio: image: pgsty/silo:RELEASE.2026-09-16T00-00-00Z restart: unless-stopped @@ -230,11 +254,13 @@ secrets: file: ./secrets/s3_access_key_id s3_secret_access_key: file: ./secrets/s3_secret_access_key - + rabbitmq_password: + file: ./secrets/rabbitmq_password volumes: postgres_data: redis_data: minio_data: + rabbitmq_data: networks: internal: