Add replay for flow alerts and hits

This commit is contained in:
dirtydishes 2026-01-09 17:09:05 -05:00
parent 2752025fbc
commit 6951dddfdf
3 changed files with 142 additions and 32 deletions

View file

@ -38,6 +38,9 @@ import {
ensureFlowPacketsTable,
ensureOptionNBBOTable,
ensureOptionPrintsTable,
fetchAlertsAfter,
fetchClassifierHitsAfter,
fetchFlowPacketsAfter,
fetchRecentAlerts,
fetchRecentClassifierHits,
fetchRecentEquityPrintJoins,
@ -916,6 +919,30 @@ const run = async () => {
return jsonResponse({ data, next });
}
if (req.method === "GET" && url.pathname === "/replay/flow") {
const { afterTs, afterSeq, limit } = parseReplayParams(url);
const data = await fetchFlowPacketsAfter(clickhouse, afterTs, afterSeq, limit);
const last = data.at(-1);
const next = last ? { ts: last.source_ts, seq: last.seq } : null;
return jsonResponse({ data, next });
}
if (req.method === "GET" && url.pathname === "/replay/classifier-hits") {
const { afterTs, afterSeq, limit } = parseReplayParams(url);
const data = await fetchClassifierHitsAfter(clickhouse, afterTs, afterSeq, limit);
const last = data.at(-1);
const next = last ? { ts: last.source_ts, seq: last.seq } : null;
return jsonResponse({ data, next });
}
if (req.method === "GET" && url.pathname === "/replay/alerts") {
const { afterTs, afterSeq, limit } = parseReplayParams(url);
const data = await fetchAlertsAfter(clickhouse, afterTs, afterSeq, limit);
const last = data.at(-1);
const next = last ? { ts: last.source_ts, seq: last.seq } : null;
return jsonResponse({ data, next });
}
if (req.method === "GET" && url.pathname === "/ws/options") {
if (serverRef.upgrade(req, { data: { channel: "options" } })) {
return new Response(null, { status: 101 });