lab5: брокер RabbitMQ, worker и асинхронная обработка

This commit is contained in:
2026-11-05 01:17:58 +03:00
parent 1982bdb690
commit d19824f546
44 changed files with 3486 additions and 150 deletions
+9 -6
View File
@@ -97,12 +97,15 @@ export class MessagesService {
// чужую заявку сняли между нашими двумя запросами (503).
if (!(await this.idempotency.isMember(chatId, currentUser.id)))
throw new NotFoundException();
// Unknown, foreign-chat or unfinished attachment: not found.
if (
ids.length > 0 &&
!(await this.attachments.allLinkable(chatId, ids))
)
throw new NotFoundException();
// Unknown or foreign-chat ids are 404; an attachment whose
// processing failed is a conflict, not a missing object.
const linkState =
ids.length > 0
? await this.attachments.linkState(chatId, ids)
: 'ok';
if (linkState === 'failed')
throw new ConflictException('Attachment processing failed');
if (linkState === 'missing') throw new NotFoundException();
this.metrics.increment('idempotency.claim_lost');
throw new ServiceUnavailableException(
'Idempotency key could not be claimed',