Use one recovery routine at start and on every sweep tick #542

Closed
opened 2026-10-15 11:57:19 +02:00 by clawbot · 1 comment
Collaborator

Approved by sneak on #499 (comment).

Change. The start-up recovery pass and the 60-second sweep become one routine in internal/delivery, run once at start and on every tick. It takes a minimum age for pending rows: zero at start, today's 15 minutes on a tick. A retrying delivery is scheduled after whatever is left of its backoff, where nothing left means now; that removes backoffElapsed.

Why. Both passes do the same job: list the webhooks, list each one's retrying and pending deliveries, settle those that already have a successful attempt, and hand the rest to takeForRedispatch. Today that job is written twice, in two parallel sets of functions. With one routine a reader learns one recovery path. Recovery stays in the engine, as recorded on #85.

What it touches. internal/delivery/engine.go: recoverPending, recoverInFlight, recoverWebhookDeliveries, recoverRetryingDeliveries, recoverSingleRetry, recoverPendingDeliveries, recoverPendingBatch, retrySweep, sweepOrphanedRetries, sweepWebhookRetries, sweepWebhookPending, sweepSingleRetry; target.go (the rescheduler interface: remainingBackoff, backoffElapsed) and its implementation in target_http.go; the README's text on start-up recovery and the sweep.

Trap. The two passes are not identical today: the tick must not queue a delivery this process is already working on or already holds a retry timer for (see the inflight checks), and start-up may do things the tick does not. Before merging them, list every difference; the one routine keeps each guard, and the PR body names each difference and how the routine handles it.

Definition of done. One set of functions does recovery at start and on each tick; backoffElapsed and the duplicate functions are gone. Behaviour is as today, covered by tests at start and on a tick for: a retrying delivery whose backoff has passed, one whose backoff has not, a pending delivery older and younger than the age bound, a delivery that already has a successful attempt, and one the engine is working on. The README describes one routine.

Builds after #540, which changes the same delivery code.

Model: opus-5-5

Approved by sneak on https://git.eeqj.de/sneak/webhooker/issues/499#issuecomment-142500. **Change.** The start-up recovery pass and the 60-second sweep become one routine in `internal/delivery`, run once at start and on every tick. It takes a minimum age for `pending` rows: zero at start, today's 15 minutes on a tick. A `retrying` delivery is scheduled after whatever is left of its backoff, where nothing left means now; that removes `backoffElapsed`. **Why.** Both passes do the same job: list the webhooks, list each one's `retrying` and `pending` deliveries, settle those that already have a successful attempt, and hand the rest to `takeForRedispatch`. Today that job is written twice, in two parallel sets of functions. With one routine a reader learns one recovery path. Recovery stays in the engine, as recorded on https://git.eeqj.de/sneak/webhooker/issues/85. **What it touches.** `internal/delivery/engine.go`: `recoverPending`, `recoverInFlight`, `recoverWebhookDeliveries`, `recoverRetryingDeliveries`, `recoverSingleRetry`, `recoverPendingDeliveries`, `recoverPendingBatch`, `retrySweep`, `sweepOrphanedRetries`, `sweepWebhookRetries`, `sweepWebhookPending`, `sweepSingleRetry`; `target.go` (the `rescheduler` interface: `remainingBackoff`, `backoffElapsed`) and its implementation in `target_http.go`; the README's text on start-up recovery and the sweep. **Trap.** The two passes are not identical today: the tick must not queue a delivery this process is already working on or already holds a retry timer for (see the `inflight` checks), and start-up may do things the tick does not. Before merging them, list every difference; the one routine keeps each guard, and the PR body names each difference and how the routine handles it. **Definition of done.** One set of functions does recovery at start and on each tick; `backoffElapsed` and the duplicate functions are gone. Behaviour is as today, covered by tests at start and on a tick for: a `retrying` delivery whose backoff has passed, one whose backoff has not, a `pending` delivery older and younger than the age bound, a delivery that already has a successful attempt, and one the engine is working on. The README describes one routine. Builds after https://git.eeqj.de/sneak/webhooker/issues/540, which changes the same delivery code. Model: opus-5-5
clawbot self-assigned this 2026-10-15 11:57:19 +02:00
Author
Collaborator

Built in #553: one routine recovers deliveries at start and on every tick. The PR body lists each difference between the two old passes and how the routine handles it.

Model: opus-5-5

Built in https://git.eeqj.de/sneak/webhooker/pulls/553: one routine recovers deliveries at start and on every tick. The PR body lists each difference between the two old passes and how the routine handles it. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#542