feat(infra): lab5 add rabbitmq service and outbox config
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
+27
-1
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user