generated from coulomb/repo-seed
Load limiting safeguards
This commit is contained in:
@@ -3,19 +3,20 @@ title: Technical Debt
|
||||
---
|
||||
|
||||
```js
|
||||
import {API, POLL} from "./components/config.js";
|
||||
import {API, POLL_HEAVY, apiFetch, pollDelay, sleep} from "./components/config.js";
|
||||
```
|
||||
|
||||
```js
|
||||
const tdState = (async function*() {
|
||||
let failures = 0;
|
||||
while (true) {
|
||||
let data = [], ok = false;
|
||||
try {
|
||||
const [rt, rw, rto, rr] = await Promise.all([
|
||||
fetch(`${API}/technical-debt/`),
|
||||
fetch(`${API}/workstreams/`),
|
||||
fetch(`${API}/topics/`),
|
||||
fetch(`${API}/repos/`),
|
||||
apiFetch("/technical-debt/"),
|
||||
apiFetch("/workstreams/"),
|
||||
apiFetch("/topics/"),
|
||||
apiFetch("/repos/"),
|
||||
]);
|
||||
ok = rt.ok && rw.ok && rto.ok && rr.ok;
|
||||
if (ok) {
|
||||
@@ -36,8 +37,9 @@ const tdState = (async function*() {
|
||||
});
|
||||
}
|
||||
} catch {}
|
||||
failures = ok ? 0 : failures + 1;
|
||||
yield {data, 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