webhook feature implemented#42
Merged
Merged
Conversation
MaryammAli
approved these changes
Jun 29, 2026
MaryammAli
left a comment
Contributor
There was a problem hiding this comment.
LGTM
thanks for ur contribution
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.
closes #28
Summary of my implementation
src/webhook.rs
WebhookPayload — serializable event envelope with idempotency_key derived from tx hash + event index
DeadLetterEntry — captures failed deliveries (url, payload, attempts, last_error, failed_at)
WebhookDispatcher — contacts URLs sequentially in registration order, never skipping on failure
deliver_with_retry — exponential backoff: min(base * 2^attempt, max) + jitter(capped/4)
dispatch_background(Arc, event) — fire-and-forget via tokio::spawn
drain_dlq() / dlq_depth() — DLQ management, bounded at 10 000 entries
from_app_config — wires directly from AppConfig
src/metrics.rs
Added webhook_deliveries_total{status}, webhook_delivery_latency_seconds{status}, webhook_dlq_depth, webhook_retries_total
src/config.rs
5 new fields: webhook_max_retries (5), webhook_retry_base_delay_ms (200 ms), webhook_retry_max_delay_ms (30 s), webhook_request_timeout_ms (10 s), webhook_jitter_enabled (true)
Validation: base ≤ max delay, non-zero delays, boolean parsing
Corresponding env vars: WEBHOOK_MAX_RETRIES, WEBHOOK_RETRY_BASE_DELAY_MS, WEBHOOK_RETRY_MAX_DELAY_MS, WEBHOOK_REQUEST_TIMEOUT_MS, WEBHOOK_JITTER_ENABLED
src/lib.rs — registered pub mod webhook
src/main.rs — WebhookDispatcher in AppState, GET /webhooks/dlq, POST /webhooks/dlq/drain
README.md — added Webhook Delivery section with event payload schema, header table, retry formula, ordering/DLQ semantics, updated env-var table and metrics tables with alerting rules