Add the failed registry, an explicit replay and failed staging retention
python -m messenger.admin is a new process assembly over the attachments zone with only a database: "failed" lists failed jobs (served by the new partial index jobs_failed_idx), "replay --attachment-id" moves a failed attachment back to queued with the same job_id, attempt 1 and a fresh outbox row, writing a replayed event with the operator. A ready, queued or processing attachment is a noop (replay_noop event), a failed one whose staging is already gone is expired. Every request is audited. The relay now also removes the staging object of a failed attachment once STAGING_RETENTION_SECONDS have passed since it failed; replay and the cleanup take the same row lock. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
ecb4827e75
commit
b568fcf9c9
@@ -1,4 +1,9 @@
|
||||
from messenger.attachments.domain.events import AttachmentDiscarded, AttachmentQueued, JobSettled
|
||||
from messenger.attachments.domain.events import (
|
||||
AttachmentDiscarded,
|
||||
AttachmentQueued,
|
||||
AttachmentReplayRequested,
|
||||
JobSettled,
|
||||
)
|
||||
from messenger.shared.application.messagebus import EventBus
|
||||
from messenger.shared.application.ports import Logger
|
||||
|
||||
@@ -15,6 +20,8 @@ LOG_FIELDS = frozenset(
|
||||
"outcome",
|
||||
"error_code",
|
||||
"delay_seconds",
|
||||
"operator",
|
||||
"result",
|
||||
}
|
||||
)
|
||||
|
||||
@@ -54,9 +61,18 @@ class AttachmentsJournal:
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user