gitflarePublicPartly agent-ready50
cf-d1-queues-pulse
Event analytics on Cloudflare D1 and Queues: ingestion API, batched consumer, rollups, live dashboard, load generator, dead-letter view.
- LicenseApache-2.0
- LanguageTypeScript
- Last landed
8a65841Oct 20, 2026
Build the full D1 + Queues pulse app: dashboard, load generator, dead letters, percentiles, docs
8a65841#!/usr/bin/env node// Usage: node scripts/load.mjs <baseUrl> [rate=20] [seconds=10]const base = (process.argv[2] || "http://localhost:8787").replace(/\/$/, "");const rate = Math.max(1, Math.min(500, Number(process.argv[3]) || 20));const seconds = Math.max(1, Number(process.argv[4]) || 10);const types = ["pageview", "click", "signup", "purchase"];const paths = ["/", "/pricing", "/docs", "/blog"];const countries = ["US", "DE", "BR", "IN", "JP"];const pick = (a) => a[Math.floor(Math.random() * a.length)];let sent = 0, failed = 0;const tick = async () => { const ts = Date.now(); const batch = Array.from({ length: rate }, () => ({ type: pick(types), path: pick(paths), country: pick(countries), value: Math.round(Math.random() * 1000), ts, })); for (let i = 0; i < batch.length; i += 100) { try { const r = await fetch(base + "/api/events", { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(batch.slice(i, i + 100)), }); if (r.ok) sent += Math.min(100, batch.length - i); else failed++; } catch { failed++; } }};for (let s = 0; s < seconds; s++) { const started = Date.now(); await tick(); process.stdout.write(`\r${s + 1}/${seconds}s sent=${sent} failed_requests=${failed}`); await new Promise((r) => setTimeout(r, Math.max(0, 1000 - (Date.now() - started))));}console.log("\ndone");