Skip to content

Commit 2acdaaa

Browse files
committed
perf: pace camera health probes
1 parent d706456 commit 2acdaaa

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎.github/scripts/check-camera-health.mjs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const PROXY_BASE = process.env.CAMERA_PROXY_URL || "https://camera-proxy.eplus.d
44
const ORIGIN = process.env.CAMERA_PROXY_ORIGIN || "https://eplus.dev"
55
const CONCURRENCY = Number(process.env.CAMERA_HEALTH_CONCURRENCY || 12)
66
const TIMEOUT_MS = Number(process.env.CAMERA_HEALTH_TIMEOUT_MS || 6000)
7+
const DELAY_MS = Number(process.env.CAMERA_HEALTH_DELAY_MS || 250)
78
const OFFLINE_AFTER = Number(process.env.CAMERA_HEALTH_OFFLINE_AFTER || 2)
89
const PREVIOUS_URL =
910
process.env.CAMERA_HEALTH_PREVIOUS_URL ||
@@ -164,6 +165,9 @@ async function mapLimit(items, concurrency, mapper) {
164165
const index = cursor++
165166
if (index >= items.length) return
166167
results[index] = await mapper(items[index], index)
168+
if (DELAY_MS > 0) {
169+
await new Promise((resolve) => setTimeout(resolve, DELAY_MS))
170+
}
167171
}
168172
}
169173

@@ -244,6 +248,7 @@ async function main() {
244248
checker: {
245249
concurrency: CONCURRENCY,
246250
timeoutMs: TIMEOUT_MS,
251+
delayMs: DELAY_MS,
247252
offlineAfterConsecutiveFailures: OFFLINE_AFTER,
248253
},
249254
...summary,

0 commit comments

Comments
 (0)