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
+8 -4
View File
@@ -5,7 +5,9 @@
// <отправка мс>,<длительность мс>,<статус>,<X-Instance-Id>» в файл консоли
// k6 (--console-output); setup() пишет «up-t0,<мс>» — начало нагрузки на
// часах ВМ: окно замера — [t0 + RAMP_S, t0 + RAMP_S + WINDOW_S). WARMUP=1 —
// одна разогревающая загрузка, она должна получить 201.
// одна разогревающая загрузка, она должна получить код успеха. Успех — 202, у
// варианта с образом commit до перехода на 202 — 201 (design change
// async-attachments, решение 16); чей код чей, считает bench/uploads.py.
import exec from "k6/execution";
import http from "k6/http";
import { fail, sleep } from "k6";
@@ -25,6 +27,7 @@ const CLIENTS = Number(__ENV.CLIENTS || 1);
const RAMP_S = Number(__ENV.RAMP_S || 3);
const WINDOW_S = Number(__ENV.WINDOW_S || 20);
const WARMUP = __ENV.WARMUP === "1";
const SUCCESS = [201, 202];
// больше timeout server LB пути загрузки (30 с): клиент видит ответ LB
const TIMEOUT = "60s";
const URL = `${API}/chats/${fixture.readChatId}/attachments?filename=bench.png`;
@@ -83,16 +86,17 @@ export default function () {
headers: HEADERS,
responseType: "none",
timeout: TIMEOUT,
responseCallback: http.expectedStatuses(201),
responseCallback: http.expectedStatuses(...SUCCESS),
});
report(start, res);
if (WARMUP && res.status !== 201) {
const success = SUCCESS.includes(res.status);
if (WARMUP && !success) {
fail(`warmup upload: ${res.status}`);
}
if (res.status === 429) {
const retry = Number(res.headers["Retry-After"]);
sleep(retry > 0 ? retry : 1);
} else if (res.status !== 201) {
} else if (!success) {
sleep(1);
}
}