feat(webhooks): add dead-letter status and lag metrics to the delivery queue (#165) - #297
Merged
Merged
Conversation
…y queue (accensa#165) The webhook delivery queue already retried failed deliveries with exponential backoff, but gave up silently into a generic 'failed' status with no explicit dead-letter state, and exposed no lag signal for the consumer fleet to scale on. This completes those two acceptance criteria: - Exhausted deliveries now land in an explicit 'dead_letter' status (kept for operator inspection, never retried again) instead of a transient-looking 'failed' row; webhookSummary counts and lists them alongside failures. - pendingDue() reports the queue's lag — deliveries due for (re)delivery right now — surfaced both in the delivery summary and in the /api/webhooks/deliver response, so a scheduler can scale consumer frequency to backlog. Closes accensa#165
|
@lorenzo-romano is attempting to deploy a commit to the ACCENSA Team on Vercel. A member of the Team first needs to authorize it. |
|
@lorenzo-romano Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Completes the two remaining acceptance criteria of #165 for the webhook delivery queue that is already on
main(webhooks.ts+webhook_deliveries/webhook_attempts): an explicit dead-letter queue and a lag signal for consumer auto-scaling.1. Dead-letter queue
MAX_ATTEMPTS) or its 24h delivery window now lands in an explicitdead_letterstatus instead of a genericfailedrow — kept for operator inspection, never retried again.webhookSummarycounts it (deadLetter) and lists dead-lettered rows inrecentFailed.deliverDuecounts dead-lettered rows as terminal failures in its run tallies.2. Lag-based auto-scaling signal
pendingDue()reports the queue's lag: deliveries due for (re)delivery right now.webhookSummary(lag) and in theGET /api/webhooks/deliverresponse, so a cron scheduler can scale consumer frequency to backlog — when lag stays high, run more frequent/overlapping deliveries; at zero, the queue is drained.No schema change required:
statusis aVARCHAR(20)column, sodead_letterfits as-is.Test Plan
pendingDueandwebhookSummary(lag + dead-letter accounting) inwebhooks.test.ts, following the file's existing fake-client conventions.webhooks.test.tssuites unchanged and compatible (therecordAttemptterminal-state change is covered by the new summary tests).Closes #165