From 6652fb8bc483f42baa5960bf37c7a884701c22e5 Mon Sep 17 00:00:00 2001 From: xCyanGrizzly Date: Tue, 26 May 2026 19:53:12 +0200 Subject: [PATCH] feat(config): add three scan-skip tuning env vars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit WORKER_SKIP_RECENT_SCAN_WINDOW_MS (default 300000 = 5 min) WORKER_EMPTY_SCAN_BACKOFF_THRESHOLD (default 5 cycles) WORKER_EMPTY_SCAN_BACKOFF_EVERY_NTH (default 5) All optional with safe defaults. Not yet read by any code — the worker integration lands in follow-up commits. Co-Authored-By: Claude Opus 4.7 (1M context) --- worker/src/util/config.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/worker/src/util/config.ts b/worker/src/util/config.ts index 6f177a6..abe8fbe 100644 --- a/worker/src/util/config.ts +++ b/worker/src/util/config.ts @@ -24,4 +24,22 @@ export const config = { * stops auto-retrying and lets the watermark advance past it. The user can * manually retry via the UI to reset and try again. */ maxSkipAttempts: parseInt(process.env.WORKER_MAX_SKIP_ATTEMPTS ?? "5", 10), + /** Window in which a recent successful empty scan lets us skip the next + * scan entirely. Default 5 minutes. */ + skipRecentScanWindowMs: parseInt( + process.env.WORKER_SKIP_RECENT_SCAN_WINDOW_MS ?? "300000", + 10 + ), + /** After this many consecutive empty scans, a channel/topic enters + * backoff and is only scanned every Nth cycle. */ + emptyScanBackoffThreshold: parseInt( + process.env.WORKER_EMPTY_SCAN_BACKOFF_THRESHOLD ?? "5", + 10 + ), + /** While in backoff, scan only every Nth cycle. Default 5 = scan every + * fifth cycle = once every ~5 hours given the 60-min default interval. */ + emptyScanBackoffEveryNth: parseInt( + process.env.WORKER_EMPTY_SCAN_BACKOFF_EVERY_NTH ?? "5", + 10 + ), } as const;