Use one recovery routine at start and on every sweep tick (closes #542)
check / check (push) Waiting to run

Start-up recovery and the 60-second sweep were two parallel sets of
functions doing the same job. recoverDeliveries now does it, run once at
start and then on every tick from one goroutine. A retrying delivery is
scheduled after what is left of its backoff, now if nothing is left, so
backoffElapsed is gone. The run at start still takes every pending
delivery and opens a webhook database whose file is missing; a tick
still takes only pending deliveries untouched for 15 minutes, at most
500, and skips a missing file. A retrying delivery is taken before its
event is read. The README describes one routine.

Model: opus-5-5
This commit was merged in pull request #553.
This commit is contained in:
2026-10-15 21:57:05 +02:00
parent 0cdda43e6c
commit ded39aa158
16 changed files with 705 additions and 594 deletions
+11 -16
View File
@@ -281,32 +281,27 @@ func (e *Engine) ExportRecoverPendingDeliveries(
ctx context.Context,
webhookDB *gorm.DB,
webhookID string,
atStart bool,
) {
e.recoverPendingDeliveries(
ctx, webhookDB, webhookID,
ctx, webhookDB, webhookID, atStart,
)
}
// ExportRecoverWebhookDeliveries exposes
// recoverWebhookDeliveries.
func (e *Engine) ExportRecoverWebhookDeliveries(
ctx context.Context, webhookID string,
ctx context.Context, webhookID string, atStart bool,
) {
e.recoverWebhookDeliveries(ctx, webhookID)
e.recoverWebhookDeliveries(ctx, webhookID, atStart)
}
// ExportRecoverInFlight exposes recoverInFlight.
func (e *Engine) ExportRecoverInFlight(
ctx context.Context,
// ExportRecoverDeliveries exposes recoverDeliveries, the recovery
// routine.
func (e *Engine) ExportRecoverDeliveries(
ctx context.Context, atStart bool,
) {
e.recoverInFlight(ctx)
}
// ExportSweepWebhookRetries exposes sweepWebhookRetries.
func (e *Engine) ExportSweepWebhookRetries(
ctx context.Context, webhookID string,
) {
e.sweepWebhookRetries(ctx, webhookID)
e.recoverDeliveries(ctx, atStart)
}
// ExportStart exposes start for testing.
@@ -353,9 +348,9 @@ func (e *Engine) ExportRetainDelivery(deliveryID string) bool {
// ExportRecoverRetryingDeliveries exposes recoverRetryingDeliveries.
func (e *Engine) ExportRecoverRetryingDeliveries(
webhookDB *gorm.DB, webhookID string,
ctx context.Context, webhookDB *gorm.DB, webhookID string,
) {
e.recoverRetryingDeliveries(webhookDB, webhookID)
e.recoverRetryingDeliveries(ctx, webhookDB, webhookID)
}
// ExportFailMissingTarget exposes failMissingTarget, so a test can hand