feat(worker): lab5 add retries, DLQ registry and manual replay endpoint

This commit is contained in:
Голиков Maximillian Антон
2026-11-10 19:08:15 +03:00
parent dce767a156
commit f748c09e10
7 changed files with 84 additions and 0 deletions
@@ -307,4 +307,13 @@ func (r *AttachmentRepo) ScheduleRetry(ctx context.Context, id string, nextAttem
return mapError(err)
}
func (r *AttachmentRepo) ResetForReplay(ctx context.Context, tx domain.Tx, id string) error {
const q = `
UPDATE attachments
SET status = 'queued', attempts = 0, error_code = NULL, locked_until = NULL, next_attempt_at = NULL, updated_at = now()
WHERE id = $1::uuid AND status = 'failed'
`
return tx.Exec(ctx, q, id)
}
var _ domain.AttachmentRepository = (*AttachmentRepo)(nil)
@@ -39,4 +39,13 @@ func (r *FailedJobRepo) Resolve(ctx context.Context, attachmentID string, resolu
return mapError(err)
}
func (r *FailedJobRepo) ResolveInTx(ctx context.Context, tx domain.Tx, id string) error {
const q = `
UPDATE failed_jobs
SET resolved_at = now(), resolution = 'manual_replay'
WHERE attachment_id = $1::uuid AND resolved_at IS NULL
`
return tx.Exec(ctx, q, id)
}
var _ domain.FailedJobRepository = (*FailedJobRepo)(nil)