Load limiting safeguards

This commit is contained in:
2026-05-06 04:04:53 +02:00
parent 47f6971c56
commit 2484ed2815
22 changed files with 374 additions and 144 deletions

View File

@@ -3,20 +3,21 @@ title: Workstreams
---
```js
import {API, POLL} from "./components/config.js";
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
```
```js
// Fetch workstreams + topics + summary (for dep graph) in parallel
const wsState = (async function*() {
let failures = 0;
while (true) {
let data = [], openWs = [], ok = false;
try {
const [rw, rt, rr, rs] = await Promise.all([
fetch(`${API}/workstreams/`),
fetch(`${API}/topics/`),
fetch(`${API}/repos/`),
fetch(`${API}/state/summary`),
apiFetch("/workstreams/"),
apiFetch("/topics/"),
apiFetch("/repos/"),
apiFetch("/state/summary", {timeout: 20_000}),
]);
ok = rw.ok && rt.ok && rr.ok && rs.ok;
if (ok) {
@@ -32,8 +33,9 @@ const wsState = (async function*() {
openWs = summary.open_workstreams ?? [];
}
} catch {}
failures = ok ? 0 : failures + 1;
yield {data, openWs, ok, ts: new Date()};
await new Promise(res => setTimeout(res, POLL));
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
}
})();
```