Files
mtusi2026lab6/src/messenger/admin.py
T
Artyom 12db77133f Forward the lab 5 foundation while preserving lab 6 telemetry
Source: immutable lab5 snapshot f88e9ba43cdfd7eb6a5a7ae5feb4247b4e820071; forward the allowed diff from 64d5c67. Carry SQLAlchemy, Alembic, reliability fixes, versioned jobs, infrastructure and student tests without changing protected coursework files.

Validation: make check, validate, lint; 515 student tests passed with one Linux-only skip; public smoke with telemetry enabled and repeat migration passed. Stop the owned stack and retain volumes. Preserve the existing OTel work in progress; grade implementation remains a separate phase.
2026-11-06 12:29:35 +03:00

38 lines
1.3 KiB
Python

import asyncio
import sys
from dishka import make_async_container
from messenger.attachments.domain.jobs import ReplayResult, ReprocessResult
from messenger.attachments.entrypoints.admin import rendered, run
from messenger.attachments.entrypoints.ioc import AdminProvider
from messenger.attachments.entrypoints.journal import LOG_FIELDS, subscribe_journal
from messenger.shared.application.messagebus import EventBus
from messenger.shared.config import PlatformSettings
from messenger.shared.entrypoints.ioc import PlatformProvider
from messenger.shared.infrastructure.logging import PLATFORM_FIELDS, StructlogLogger
async def serve(argv: list[str]) -> int:
platform = PlatformSettings()
logger = StructlogLogger(level=platform.log_level, allowed_fields=PLATFORM_FIELDS | LOG_FIELDS)
container = make_async_container(PlatformProvider(platform, logger), AdminProvider())
bus = await container.get(EventBus)
subscribe_journal(bus, logger)
bus.start()
try:
report = await run(container, argv)
finally:
await bus.stop()
await container.close()
sys.stdout.write(rendered(report) + "\n")
return int(report.get("result") in (ReplayResult.NOT_FOUND, ReprocessResult.CONFLICT))
def main() -> None:
sys.exit(asyncio.run(serve(sys.argv[1:])))
if __name__ == "__main__":
main()