feat: process attachments asynchronously with RabbitMQ and a worker

Upload answers 202 after staging, a queued job in PostgreSQL and a broker
confirm; a separate worker publishes the original and a thumbnail with
bounded retries. Adds the job and variant tables, the broker service, the
worker S3 user, cleanup and reconcile support for staging and variants,
the failure stand with broker and worker, bench and driver updates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-31 06:48:20 +03:00
co-authored by Claude Opus 5.5
parent 40c709a78b
commit ff1a83b6ff
107 changed files with 9765 additions and 993 deletions
+15
View File
@@ -208,6 +208,21 @@ API» называет все четыре.
проверка идут до `created_at` строки `pending`, а сроки tx1, PUT и tx2
не менялись. Поэтому `[uploads]` в проверку grace уборщика не входит.
### Брокер и worker (с лабы 5)
`[broker]` (класс `Broker`, design change `async-attachments`, решение 13):
`host`, `port`, `user`, `password` (`SecretStr`) — мосты из `RABBITMQ_*` в `.env`,
в docker — `x-broker-env`; `connect_timeout_seconds` (2),
`publish_timeout_seconds` (2; при смене пересчитать цепочку LB: после тела 29 с
< `timeout server` 30 с). `[worker]` (класс `Worker`): `concurrency` (2), `max_attempts`
(5), `job_timeout_seconds` (60), `retry_delay_seconds` (10),
`graceful_shutdown_seconds` (8, ≤ 9), `reconnect_seconds` (2). Подмена — `BROKER__*`,
`WORKER__*`. Ключи worker `S3_WORKER_*` — в `.env`, контейнеру — `environment`
compose, консоль — `make run_worker` (мост `S3__*` в `.env` — ключи API). Имена
skeleton: `BROKER_URL_FILE` → мосты `RABBITMQ_*`; `WORKER_CONCURRENCY`,
`JOB_MAX_ATTEMPTS`, `JOB_TIMEOUT_SECONDS` → поля `[worker]`;
`STAGING_RETENTION_SECONDS` — поля пока нет, появится с очисткой staging.
### Уборщик (с лабы 4)
`[cleaner]` (класс `Cleaner`, design change `upload-consistency`,