Carry over the lab 5 solution

Bring the application, own tests, Dockerfile, toolchain, compose stack,
HAProxy, k6, RustFS and RabbitMQ configuration, migrations, hooks,
scenario scripts and the CI job from the lab 5 solution commit 64d5c67,
keep the lab 5 Makefile targets on top of the unchanged skeleton
targets, and append the lab 5 solution variables to the skeleton
.env.example. The package and the application follow the contract
version 1.6.0, and the image, the throwaway test containers and the
broker vhost description are tagged lab6 so they do not collide with a
lab 5 stand on the same host.

This is the starting point of the lab 6 cycle: lint, own tests and the
offline skeleton check pass before any lab 6 change.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Artyom
2026-10-29 03:51:58 +03:00
co-authored by Claude Opus 5.5
parent a0d3947710
commit 5ae3d77152
204 changed files with 18547 additions and 1 deletions
@@ -0,0 +1,78 @@
from messenger.attachments.domain.events import (
AttachmentDiscarded,
AttachmentQueued,
AttachmentReplayRequested,
JobSettled,
)
from messenger.shared.application.messagebus import EventBus
from messenger.shared.application.ports import Logger
LOG_FIELDS = frozenset(
{
"attachment_id",
"chat_id",
"actor_id",
"size_bytes",
"count",
"job_id",
"attempt",
"pipeline_version",
"outcome",
"error_code",
"delay_seconds",
"operator",
"result",
}
)
class AttachmentsJournal:
__slots__ = ("_logger",)
def __init__(self, logger: Logger) -> None:
self._logger = logger
async def on_attachment_queued(self, event: AttachmentQueued) -> None:
self._logger.info(
"audit.attachment_queued",
attachment_id=str(event.attachment_id),
chat_id=str(event.chat_id),
actor_id=str(event.owner_id),
size_bytes=event.size_bytes,
)
async def on_attachment_discarded(self, event: AttachmentDiscarded) -> None:
self._logger.info(
"audit.attachment_discarded",
attachment_id=str(event.attachment_id),
chat_id=str(event.chat_id),
reason=event.reason,
)
async def on_job_settled(self, event: JobSettled) -> None:
self._logger.info(
"audit.job_settled",
job_id=str(event.job_id),
attachment_id=str(event.attachment_id),
pipeline_version=event.pipeline_version,
attempt=event.attempt,
outcome=event.outcome,
error_code=event.error_code,
delay_seconds=event.delay_seconds,
)
async def on_replay_requested(self, event: AttachmentReplayRequested) -> None:
self._logger.info(
"audit.attachment_replay",
attachment_id=str(event.attachment_id),
operator=event.operator,
result=event.result,
)
def subscribe_journal(bus: EventBus, logger: Logger) -> None:
journal = AttachmentsJournal(logger)
bus.subscribe(AttachmentQueued, journal.on_attachment_queued)
bus.subscribe(AttachmentDiscarded, journal.on_attachment_discarded)
bus.subscribe(JobSettled, journal.on_job_settled)
bus.subscribe(AttachmentReplayRequested, journal.on_replay_requested)