feat(worker): prepare replay queries and audit schema
This commit is contained in:
@@ -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)),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user