fix: database target writes to dedicated archive table
All checks were successful
check / check (push) Successful in 1m43s
All checks were successful
check / check (push) Successful in 1m43s
The "database" target type now writes events to a separate archived_events table instead of just marking the delivery as done. This table persists independently of internal event retention/pruning, allowing the data to be consumed by external systems or preserved indefinitely. New ArchivedEvent model copies the full event payload (method, headers, body, content_type) along with webhook/entrypoint/event/target IDs.
This commit is contained in:
@@ -244,7 +244,32 @@ func (e *Engine) deliverRetry(_ context.Context, d *database.Delivery) {
|
||||
}
|
||||
|
||||
func (e *Engine) deliverDatabase(d *database.Delivery) {
|
||||
// The event is already stored in the database; mark as delivered.
|
||||
// Write the event to the dedicated archived_events table. This table
|
||||
// persists independently of internal event retention/pruning, so the
|
||||
// data remains available for external consumption even after the
|
||||
// original event is cleaned up.
|
||||
archived := &database.ArchivedEvent{
|
||||
WebhookID: d.Event.WebhookID,
|
||||
EntrypointID: d.Event.EntrypointID,
|
||||
EventID: d.EventID,
|
||||
TargetID: d.TargetID,
|
||||
Method: d.Event.Method,
|
||||
Headers: d.Event.Headers,
|
||||
Body: d.Event.Body,
|
||||
ContentType: d.Event.ContentType,
|
||||
}
|
||||
|
||||
if err := e.database.DB().Create(archived).Error; err != nil {
|
||||
e.log.Error("failed to archive event",
|
||||
"delivery_id", d.ID,
|
||||
"event_id", d.EventID,
|
||||
"error", err,
|
||||
)
|
||||
e.recordResult(d, 1, false, 0, "", err.Error(), 0)
|
||||
e.updateDeliveryStatus(d, database.DeliveryStatusFailed)
|
||||
return
|
||||
}
|
||||
|
||||
e.recordResult(d, 1, true, 0, "", "", 0)
|
||||
e.updateDeliveryStatus(d, database.DeliveryStatusDelivered)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user