ЛР 3: Балансировка API и отказ реплики

This commit is contained in:
2026-12-02 00:16:41 +03:00
parent 0ab3a341aa
commit 25f666a3e8
22 changed files with 993 additions and 18 deletions
+17
View File
@@ -0,0 +1,17 @@
CREATE TABLE idempotency_records (
user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
http_method TEXT NOT NULL CHECK (http_method = 'POST'),
request_path TEXT NOT NULL,
idempotency_key VARCHAR(128) NOT NULL,
request_hash CHAR(64) NOT NULL,
response_status SMALLINT,
response_body JSONB,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
expires_at TIMESTAMPTZ NOT NULL,
PRIMARY KEY (user_id, http_method, request_path, idempotency_key),
CHECK ((response_status IS NULL) = (response_body IS NULL)),
CHECK (response_status IS NULL OR response_status = 201)
);
CREATE INDEX idempotency_records_expiry_idx
ON idempotency_records (expires_at);