refactor: self-contained delivery tasks — engine delivers without DB reads in happy path
All checks were successful
check / check (push) Successful in 58s
All checks were successful
check / check (push) Successful in 58s
The webhook handler now builds DeliveryTask structs carrying all target config and event data inline (for bodies ≤16KB) and sends them through the delivery channel. In the happy path, the engine delivers without reading from any database — it only writes to record delivery results. For large bodies (≥16KB), Body is nil and the engine fetches it from the per-webhook database on demand. Retry timers also carry the full DeliveryTask, so retries avoid unnecessary DB reads. The database is used for crash recovery only: on startup the engine scans for interrupted pending/retrying deliveries and re-queues them. Implements owner feedback from issue #15: > the message in the <=16KB case should have everything it needs to do > its delivery. it shouldn't touch the db until it has a success or > failure to record.
This commit is contained in:
18
README.md
18
README.md
@@ -487,8 +487,10 @@ External Service
|
||||
│
|
||||
1. Look up Entrypoint by UUID
|
||||
2. Capture full request as Event
|
||||
3. Queue Delivery to each active Target
|
||||
4. Notify Engine via channel
|
||||
3. Create Delivery records for each active Target
|
||||
4. Build self-contained DeliveryTask structs
|
||||
(target config + event data inline for ≤16KB)
|
||||
5. Notify Engine via channel (no DB read needed)
|
||||
│
|
||||
▼
|
||||
┌──────────────┐
|
||||
@@ -660,8 +662,11 @@ Components are wired via Uber fx in this order:
|
||||
|
||||
The server starts via `fx.Invoke(func(*server.Server, *delivery.Engine)
|
||||
{})` which triggers the fx lifecycle hooks in dependency order. The
|
||||
`DeliveryNotifier` interface allows the webhook handler to notify the
|
||||
delivery engine of new work without a direct package dependency.
|
||||
`DeliveryNotifier` interface allows the webhook handler to send
|
||||
self-contained `DeliveryTask` slices to the engine without a direct
|
||||
package dependency. Each task carries all target config and event data
|
||||
inline (for bodies ≤16KB), so the engine can deliver without reading
|
||||
from any database — it only writes to record results.
|
||||
|
||||
### Middleware Stack
|
||||
|
||||
@@ -752,6 +757,11 @@ linted, tested, and compiled.
|
||||
creation, delete on webhook removal)
|
||||
- [x] `WebhookDBManager` component with lazy connection pooling
|
||||
- [x] Event-driven delivery engine (channel notifications + timer-based retries)
|
||||
- [x] Self-contained delivery tasks: in the ≤16KB happy path, the engine
|
||||
delivers without reading from any database — target config, event
|
||||
headers, and body are all carried inline in the channel notification.
|
||||
The engine only touches the DB to record results (success/failure).
|
||||
Large bodies (≥16KB) are fetched from the per-webhook DB on demand.
|
||||
- [x] Database target type marks delivery as immediately successful
|
||||
(events are already in the per-webhook DB)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user