lab5: асинхронная очередь, worker и идемпотентный pipeline
API принимает 202 после durable staging и TX intent (job+outbox); отдельные relay и worker публикуют/обрабатывают задания с publisher confirm, lease, retry/backoff, DLQ и replay. Добавлены версии pipeline, варианты thumbnail/crop/optimized, presign в verified staging, status-aware sweeper и admission control.
This commit is contained in:
@@ -19,7 +19,7 @@ from client import Client, Failure, arguments, check, run # noqa: E402
|
||||
FIXTURE = Path(__file__).resolve().parents[1] / 'tests/fixtures/sample.png'
|
||||
|
||||
|
||||
def upload(client, actor, chat, content, filename='sample.png', content_type='image/png', expected=201):
|
||||
def upload(client, actor, chat, content, filename='sample.png', content_type='image/png', expected=202):
|
||||
path = '/api/v1/chats/' + chat['id'] + '/attachments?filename=' + quote(filename, safe='')
|
||||
return client.call('POST', path, expected, actor=actor, raw=content, headers={'Content-Type': content_type})
|
||||
|
||||
@@ -92,16 +92,18 @@ def main():
|
||||
)
|
||||
print('duplicate attachment ids: 400')
|
||||
|
||||
# The only variant in the lab4 contract is original; other values are 400.
|
||||
# Lab5 exposes the derived variants after ready; queued content is a conflict.
|
||||
own, content = client.attachment(alice, chat)
|
||||
client.call('GET', '/api/v1/attachments/' + own['id'] + '/content?variant=thumbnail', 400, actor=alice)
|
||||
client.call('GET', '/api/v1/attachments/' + own['id'] + '/content', 409, actor=alice)
|
||||
own = client.wait_ready(alice, own)
|
||||
client.call('GET', '/api/v1/attachments/' + own['id'] + '/content?variant=thumbnail', 200, actor=alice)
|
||||
|
||||
# Attachment-only message is valid.
|
||||
client.message(alice, chat, '', attachments=[own['id']])
|
||||
print('attachment-only message: 201')
|
||||
|
||||
# Object keys are server-generated; anonymous direct access must be denied.
|
||||
key = 'attachments/' + chat['id'] + '/' + own['id']
|
||||
key = 'attachments/' + chat['id'] + '/' + own['id'] + '/original'
|
||||
request = urllib.request.Request('http://127.0.0.1:8333/messenger-attachments/' + key, method='GET')
|
||||
try:
|
||||
urllib.request.urlopen(request, timeout=5)
|
||||
|
||||
Reference in New Issue
Block a user