Add flow packet clustering

This commit is contained in:
dirtydishes 2025-12-27 20:25:32 -05:00
parent a21d513f32
commit 6c376b26dc
8 changed files with 347 additions and 11 deletions

View file

@ -13,7 +13,9 @@ import {
import {
createClickHouseClient,
ensureEquityPrintsTable,
ensureFlowPacketsTable,
ensureOptionPrintsTable,
fetchRecentFlowPackets,
fetchEquityPrintsAfter,
fetchRecentEquityPrints,
fetchOptionPrintsAfter,
@ -141,6 +143,7 @@ const run = async () => {
await ensureOptionPrintsTable(clickhouse);
await ensureEquityPrintsTable(clickhouse);
await ensureFlowPacketsTable(clickhouse);
const optionSubscription = await subscribeJson(
js,
@ -208,6 +211,12 @@ const run = async () => {
return jsonResponse({ data });
}
if (req.method === "GET" && url.pathname === "/flow/packets") {
const limit = parseLimit(url.searchParams.get("limit"));
const data = await fetchRecentFlowPackets(clickhouse, limit);
return jsonResponse({ data });
}
if (req.method === "GET" && url.pathname === "/replay/options") {
const { afterTs, afterSeq, limit } = parseReplayParams(url);
const data = await fetchOptionPrintsAfter(clickhouse, afterTs, afterSeq, limit);