configure db target type for archiving #43
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
no. the database target type should have a configurable expiry (default: never) and should log events to a separate per-webhook archive sqlite file for long term storage. the file should be created if it does not exist and should be closed and reopened after each write (unless the last reopen was less than one second ago) and should support auto-recreate for the case where the archive sqlite db file is moved away for archiving.
Implementation instructions
The
Targetinterface (#77) is now merged, so implement this as thedatabaseTargetimplementation.Authoritative spec (from @sneak on this issue): the database target should have a configurable expiry (default: never) and should log events to a SEPARATE per-webhook archive sqlite file for long-term storage. The file is created if it does not exist; it is closed and reopened after each write (unless the last reopen was less than one second ago); and it supports auto-recreate for the case where the archive sqlite file is moved away for archiving.
Scope:
internal/delivery/target_database.goplus a new archive-writer file it needs (keep it in thedeliveryordatabasepackage). Touchinternal/config/config.goonly if a genuinely global setting is required — prefer per-target config. Do NOT change theTargetinterface or other targets.Behaviour:
databaseTarget.Deliverwrites the full event (body, headers, method, content type, webhook id, entrypoint id, timestamp) as a row into a per-webhook archive sqlite file that is DISTINCT from the per-webhook event DB — e.g.archive-{webhookID}.dbunder the data dir. Create the file and its schema if missing.Target.Config), default "never" (keep forever). When an expiry is set, prune archived rows older than it — implementer's choice of mechanism (on open, or reuse the retention-sweep pattern), documented in the code. Default "never" means no pruning.Definition of done:
databasetarget writes the full event into a separate per-webhook archive sqlite file, created if absentGates and process:
make fmt; validate withdocker build .(must exit 0)mainnamedissue-43-database-archiving; commit subject ends with(closes #43)main) and comment on it with the diff summary and thedocker build .result; no AI/tooling referencesmainwas just updated with the delivery refactor, the retention reaper, and NoCache. Ifdocker buildfails on something unrelated to your change, check whether an unmodifiedorigin/mainbuilds, and if it does not, STOP and report thatmainitself is broken rather than trying to fix it.