feat(worker): prepare replay queries and audit schema

This commit is contained in:
kk10
2026-11-16 16:18:54 +03:00
parent 97b43a9c98
commit f2000a7883
7 changed files with 239 additions and 10 deletions
+4 -4
View File
@@ -39,7 +39,7 @@ func (w *Worker) finishFailure(ctx context.Context, job model.AttachmentJob, cau
}
var n int64
if permanent || row.Attempts >= w.cfg.MaxAttempts {
if permanent || row.Attempts-row.RetryBase >= w.cfg.MaxAttempts {
if !permanent {
code = "retry_exhausted"
}
@@ -59,7 +59,7 @@ func (w *Worker) finishFailure(ctx context.Context, job model.AttachmentJob, cau
_, err = q.CreateOutboxEntry(ctx, db.CreateOutboxEntryParams{
AttachmentID: row.ID,
Attempt: row.Attempts + 1,
AvailableAt: time.Now().Add(retryDelay(row.Attempts)),
AvailableAt: time.Now().Add(retryDelay(row.Attempts - row.RetryBase)),
})
}
}
@@ -119,7 +119,7 @@ func (w *Worker) recoverOne(ctx context.Context) (bool, error) {
}
row := rows[0]
if row.Attempts >= w.cfg.MaxAttempts {
if row.Attempts-row.RetryBase >= w.cfg.MaxAttempts {
_, err = q.FailExpiredAttachmentJob(ctx, row.ID)
} else {
_, err = q.RecoverExpiredAttachmentJob(ctx, row.ID)
@@ -127,7 +127,7 @@ func (w *Worker) recoverOne(ctx context.Context) (bool, error) {
_, err = q.CreateOutboxEntry(ctx, db.CreateOutboxEntryParams{
AttachmentID: row.ID,
Attempt: row.Attempts + 1,
AvailableAt: time.Now().Add(retryDelay(row.Attempts)),
AvailableAt: time.Now().Add(retryDelay(row.Attempts - row.RetryBase)),
})
}
}