лабораторная работа 3

This commit is contained in:
2026-10-23 15:06:43 +03:00
parent 0ab3a341aa
commit eeee24d3d7
53 changed files with 2476 additions and 21 deletions
+19
View File
@@ -0,0 +1,19 @@
-- Lab3 shared idempotency ledger for POST message retries.
--
-- Scope is (user_id, HTTP method + chat path, key); the stored row carries the
-- canonical request hash and the exact 201 body so any replica can replay the
-- same Message. Rows expire after IDEMPOTENCY_TTL_SECONDS (default 24h).
create table if not exists idempotency_keys (
user_id uuid not null references users (id) on delete cascade,
scope text not null,
key text not null,
request_hash text not null,
status_code integer not null,
response_body jsonb not null,
created_at timestamptz not null default now(),
expires_at timestamptz not null,
primary key (user_id, scope, key)
);
create index if not exists idempotency_keys_expires_at_idx
on idempotency_keys (expires_at);