mirror of
https://github.com/anand34577/ferrum.git
synced 2026-09-19 00:55:11 +00:00
4dfeb9848e
- internal/events: in-process pub/sub bus; GET /api/v1/events SSE stream - internal/notify/webhooks.go: signed outgoing webhook dispatcher w/ retry + delivery log - internal/api/tags.go, search.go, bulk.go: cross-remote tag aggregation, global search, fleet-wide bulk guest actions - internal/auth/sessions.go: session listing/revocation (self-service + admin), extends the existing stateful session table - internal/poller/certificates.go: cert-expiry + connection-staleness alerting via the existing alert_rules pipeline - web: useEventStream hook, GlobalSearch + BulkOperationsPage (not yet wired into nav), SessionsCard on ProfilePage
37 lines
1.6 KiB
SQL
37 lines
1.6 KiB
SQL
-- +goose Up
|
|
-- Outgoing webhook subscriptions: fan out internal/events.Bus events to
|
|
-- third-party URLs as signed POSTs. event_types is a JSON array of
|
|
-- events.Type strings (e.g. ["alert.triggered","connection.down"]); an
|
|
-- empty array means "all event types".
|
|
CREATE TABLE webhook_subscriptions (
|
|
id TEXT PRIMARY KEY,
|
|
name TEXT NOT NULL,
|
|
url TEXT NOT NULL,
|
|
secret TEXT NOT NULL, -- HMAC-SHA256 signing key, stored as-is (not a login credential; rotated by deleting/recreating)
|
|
event_types TEXT NOT NULL DEFAULT '[]',
|
|
active INTEGER NOT NULL DEFAULT 1,
|
|
created_by TEXT REFERENCES users(id) ON DELETE SET NULL,
|
|
created_at TEXT NOT NULL,
|
|
updated_at TEXT NOT NULL
|
|
);
|
|
|
|
-- Delivery log: the last N attempts per subscription, for diagnosing a
|
|
-- webhook a third party says it never received. Rows are pruned to a fixed
|
|
-- count per subscription by the dispatcher itself (see internal/notify).
|
|
CREATE TABLE webhook_deliveries (
|
|
id TEXT PRIMARY KEY,
|
|
subscription_id TEXT NOT NULL REFERENCES webhook_subscriptions(id) ON DELETE CASCADE,
|
|
event_type TEXT NOT NULL,
|
|
event_id TEXT NOT NULL,
|
|
attempt INTEGER NOT NULL,
|
|
status_code INTEGER, -- NULL when the request itself failed (timeout, DNS, connection refused, ...)
|
|
error TEXT,
|
|
success INTEGER NOT NULL DEFAULT 0,
|
|
created_at TEXT NOT NULL
|
|
);
|
|
CREATE INDEX idx_webhook_deliveries_subscription ON webhook_deliveries(subscription_id, created_at DESC);
|
|
|
|
-- +goose Down
|
|
DROP TABLE webhook_deliveries;
|
|
DROP TABLE webhook_subscriptions;
|