lab5: очереди и асинхронная обработка изображений

Durable staging handoff, transactional outbox, at-least-once worker with lease fencing, idempotent versioned pipeline, three variants, operator tooling, contract tests and evidence. Includes the review fixes: reprocess source selection and failure settlement, replay guards, stale-job retirement, PNG structural/raster validation, migration rollback safety and audit events.
This commit is contained in:
Vladislav Kunetskiy
2026-10-31 14:34:24 +03:00
parent 6c5ba026f1
commit 01b885e846
99 changed files with 10164 additions and 1452 deletions
+5 -3
View File
@@ -52,10 +52,10 @@ def put(url, content, content_type='image/png'):
return error.code
def complete(client, actor, attachment_id, digest, expected=200):
def complete(client, actor, attachment_id, digest, expected=202):
return client.call(
'POST', '/api/v1/attachments/' + attachment_id + '/complete', expected,
actor=actor, body={'sha256': digest}, schema='Attachment' if expected == 200 else None,
actor=actor, body={'sha256': digest}, schema='Attachment' if expected == 202 else None,
)
@@ -73,7 +73,8 @@ def main():
check(put(presigned['upload_url'], content) == 200, 'direct PUT failed')
attachment = complete(client, alice, presigned['attachment_id'], digest)['json']
check(attachment['sha256'] == digest and attachment['size_bytes'] == len(content), 'completed metadata mismatch')
print('happy path: direct PUT 200, complete ready, checksum/size match')
attachment = client.wait_ready(alice, attachment)
print('happy path: direct PUT 200, complete queued, ready after worker')
client.message(alice, chat, '', attachments=[attachment['id']])
download = client.call('GET', '/api/v1/attachments/' + attachment['id'] + '/content', actor=bob)
@@ -83,6 +84,7 @@ def main():
# Completion is idempotent.
again = complete(client, alice, presigned['attachment_id'], digest)['json']
check(again['id'] == attachment['id'], 'repeated complete returned another attachment')
check(again['status'] in ('queued', 'processing', 'ready'), 'repeated complete returned an invalid state')
print('repeated complete is idempotent')
# A foreign user cannot complete someone else's pending upload.