Run manual diagnostic attachments in the background

This commit is contained in:
ayurishchev committed 2026-11-22 20:50:39 +03:00
1 parent d845a5e4b6
commit 89ac4d5bcd
40 files changed
+1560 -58

No files matched your search

+7 -1
View File
@@ -10,7 +10,13 @@ import (
// event stays traceable to its address (via registry_id) and prunable at
// the right cycle boundary even after the ip_queue row itself is deleted.
func (d *DB) InsertEvent(ctx context.Context, e Event) error {
_, err := d.ExecContext(ctx, `
return insertEvent(ctx, d, e)
}
func insertEvent(ctx context.Context, q interface {
ExecContext(context.Context, string, ...any) (sql.Result, error)
}, e Event) error {
_, err := q.ExecContext(ctx, `
INSERT INTO events (source_type, source_id, ip_id, registry_id, cycle_id, event_type, payload, occurred_at, created_at)
VALUES (?, ?, ?, (SELECT registry_id FROM ip_queue WHERE id=?), COALESCE((SELECT cycle_id FROM ip_queue WHERE id=?), 0), ?, ?, ?, ?)
`, e.SourceType, e.SourceID, e.IPID, e.IPID, e.IPID, e.EventType, e.Payload, timeToDB(e.OccurredAt), timeToDB(Now()))