1 Commits
Author SHA1 Message Date
clawbot 7eba0d59f5 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
2026-10-15 19:36:34 +00:00
+5 -5
View File
@@ -40,10 +40,10 @@ const (
// explosions regardless of queue depth.
defaultWorkers = 10
// retrySweepInterval is how often the recovery routine runs
// sweepInterval is how often the recovery routine runs
// once it has run at start. Each of those runs is a tick of
// the sweep.
retrySweepInterval = 60 * time.Second
sweepInterval = 60 * time.Second
// pendingSweepMinAge is how long a delivery must have sat
// untouched at pending before the sweep will look at it.
@@ -65,7 +65,7 @@ const (
// pendingSweepBatch bounds how many stranded pending deliveries
// one tick of the sweep re-dispatches for one webhook. The sweep
// ticks every retrySweepInterval, so a larger backlog drains
// ticks every sweepInterval, so a larger backlog drains
// across successive ticks instead of arriving as one burst against
// a database that was already struggling to accept writes.
pendingSweepBatch = 500
@@ -649,11 +649,11 @@ func (e *Engine) abandonRetryForMissingTarget(
// runRecovery runs the recovery routine, recoverDeliveries, once when
// the engine starts and then on every tick of the sweep, every
// retrySweepInterval, until the engine stops.
// sweepInterval, until the engine stops.
func (e *Engine) runRecovery(ctx context.Context) {
defer e.wg.Done()
ticker := time.NewTicker(retrySweepInterval)
ticker := time.NewTicker(sweepInterval)
defer ticker.Stop()
e.recoverDeliveries(ctx, true)