generated from coulomb/repo-seed
Load limiting safeguards
This commit is contained in:
@@ -3,20 +3,21 @@ title: Interventions
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
// Live poll: all tasks (filtered client-side) + workstreams + topics
|
||||
const interventionState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let tasks = [], wsMap = {}, ok = false;
|
||||
try {
|
||||
const [rt, rw, rto, rr] = await Promise.all([
|
||||
fetch(`${API}/tasks/?limit=500`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/tasks/?limit=500"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = rt.ok && rw.ok && rto.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -36,8 +37,9 @@ const interventionState = (async function*() {
|
||||
}));
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {tasks, ok, ts: new Date()};
|
||||
await new Promise(res => setTimeout(res, POLL));
|
||||
await sleep(pollDelay({ok, base: POLL_HEAVY, failures}));
|
||||
}
|
||||
})();
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user