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
@@ -11,12 +11,14 @@ from messenger.attachments.application.commands import (
|
||||
ProcessJob,
|
||||
PublishOutbox,
|
||||
RecoverExpiredLeases,
|
||||
ReplayAttachment,
|
||||
)
|
||||
from messenger.attachments.application.pipeline import (
|
||||
CleanStagingHandler,
|
||||
ProcessJobHandler,
|
||||
PublishOutboxHandler,
|
||||
RecoverExpiredLeasesHandler,
|
||||
ReplayAttachmentHandler,
|
||||
)
|
||||
from messenger.attachments.application.ports import (
|
||||
Faults,
|
||||
@@ -25,7 +27,7 @@ from messenger.attachments.application.ports import (
|
||||
Rendition,
|
||||
VariantRenderer,
|
||||
)
|
||||
from messenger.attachments.domain.jobs import Job, Outcome, RetryPolicy
|
||||
from messenger.attachments.domain.jobs import Job, Outcome, ReplayResult, RetryPolicy
|
||||
from messenger.attachments.entrypoints.schemas import JobMessage
|
||||
from messenger.attachments.infrastructure.faults import EnvironmentFaults
|
||||
from messenger.attachments.infrastructure.images import RenderLimits, render_variants
|
||||
@@ -141,8 +143,13 @@ class InlinePipeline:
|
||||
handler = RecoverExpiredLeasesHandler(self.uow(), self.policy)
|
||||
return await handler(RecoverExpiredLeases(100))
|
||||
|
||||
async def clean(self) -> int:
|
||||
return await CleanStagingHandler(self.uow(), self.storage)(CleanStaging(100))
|
||||
async def clean(self, retention: timedelta = timedelta(days=1)) -> int:
|
||||
command = CleanStaging(100, retention)
|
||||
return await CleanStagingHandler(self.uow(), self.storage)(command)
|
||||
|
||||
async def replay(self, attachment_id: UUID, operator: str = "test") -> ReplayResult:
|
||||
command = ReplayAttachment(attachment_id, operator)
|
||||
return await ReplayAttachmentHandler(self.uow())(command)
|
||||
|
||||
|
||||
async def pipeline_of(
|
||||
|
||||
Reference in New Issue
Block a user