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
+20 -3
View File
@@ -10,15 +10,32 @@ from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
def compose(*args, check=True):
def compose(*args, check=True, env=None):
command = [*os.environ.get('COMPOSE_BIN', 'docker compose').split(), '--env-file', '.env', '-f', 'compose.yaml', *args]
environment = {**os.environ, **(env or {})}
return subprocess.run(command, cwd=ROOT, capture_output=True, text=True, check=check)
return subprocess.run(command, cwd=ROOT, capture_output=True, text=True, check=check, env=environment)
def jobctl(*args, check=True):
"""Run the operator CLI inside the worker image."""
return compose('run', '--rm', '--entrypoint', '/usr/local/bin/jobctl', 'worker', *args, check=check)
def psql(sql):
"""Read a scalar/list from the stand database (operator evidence only)."""
project = os.environ.get('COMPOSE_PROJECT_NAME', 'mtusi-messenger-lab5')
result = subprocess.run(
['docker', 'exec', project + '-postgres-1', 'psql', '-U', 'messenger', '-d', 'messenger', '-Atc', sql],
cwd=ROOT, capture_output=True, text=True, check=True,
)
return result.stdout.strip()
def containers_by_hostname(service='api'):
"""{hostname: {id, name, status}} для контейнеров сервиса."""
project = os.environ.get('COMPOSE_PROJECT_NAME', 'mtusi-messenger-lab4')
project = os.environ.get('COMPOSE_PROJECT_NAME', 'mtusi-messenger-lab5')
listed = subprocess.run(
[
'docker', 'ps', '-q',