From d27a779c201a35ef2233a2d78d6af3d0928f19e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=93=D0=BE=D0=BB=D0=B8=D0=BA=D0=BE=D0=B2=20Maximillian?= =?UTF-8?q?=20=D0=90=D0=BD=D1=82=D0=BE=D0=BD?= Date: Tue, 10 Nov 2026 12:00:48 +0300 Subject: [PATCH] feat(storage): lab5 implement ScheduleRetry for transient errors --- backend/internal/storage/postgres/attachments.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/backend/internal/storage/postgres/attachments.go b/backend/internal/storage/postgres/attachments.go index 42ec3b2..1a3981c 100644 --- a/backend/internal/storage/postgres/attachments.go +++ b/backend/internal/storage/postgres/attachments.go @@ -297,4 +297,14 @@ func (r *AttachmentRepo) FailJob(ctx context.Context, id string, errorCode strin return mapError(err) } +func (r *AttachmentRepo) ScheduleRetry(ctx context.Context, id string, nextAttemptAt time.Time, errorCode string) error { + const q = ` + UPDATE attachments + SET status = 'queued', error_code = NULL, next_attempt_at = $2, locked_until = NULL, updated_at = now() + WHERE id = $1::uuid AND status = 'processing' + ` + _, err := r.pool.Exec(ctx, q, id, nextAttemptAt) + return mapError(err) +} + var _ domain.AttachmentRepository = (*AttachmentRepo)(nil)