rails-webhooks
Installation
SKILL.md
Rails Webhooks
Use for outbound/inbound webhook architecture and reliability. Modeled on Fizzy's event-driven webhook pipeline (with Campfire's simpler bot webhooks as contrast).
Delivery Model (outbox pattern)
- Domain events enqueue one dispatch job; the dispatch job fans out, creating one persisted
Deliveryrow per webhook, each with a state enum (pending in_progress completed errored— string-backed viaindex_by(&:itself)). - Each delivery row auto-enqueues its own send via
after_create_commit :deliver_later— persist first, deliver second, so state survives crashes and retries. - Fan-out is crash-safe with
ActiveJob::Continuable: cursor over matching webhooks (find_each(start: step.cursor)+step.advance!) so a mid-batch crash resumes, not restarts. - Record request metadata (headers, payload) and response (status, body) on the delivery row for audit/debugging. Cap stored/streamed response bodies (~100KB) with a running byte count.
- Use a dedicated
webhooksqueue so slow destinations can't starve other work.
Failure Classification (the key distinction)
- Expected destination failures (timeout, TLS, DNS, connection refused, HTTP 4xx/5xx): rescue, mark delivery
completedwith a symbolic error (response: { error: :connection_timeout }). The delivery ran; the destination failed. Do not retry the job. - Unexpected exceptions (our bug): mark
errored!, re-raise so ActiveJob retries. - This split keeps retry behavior, dashboards, and delinquency tracking honest.