From 902a90af79f05379d2e978a489b3df5929c615e5 Mon Sep 17 00:00:00 2001 From: Maha Benzekri Date: Thu, 16 May 2024 17:44:41 +0200 Subject: [PATCH] fixup post review finalization --- CountItems/masterProcess.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/CountItems/masterProcess.js b/CountItems/masterProcess.js index 712a21c7..0c9f824d 100644 --- a/CountItems/masterProcess.js +++ b/CountItems/masterProcess.js @@ -24,13 +24,14 @@ let waitingForPromScraping = false; werelogs.configure(loggerConfig); const log = new werelogs.Logger('S3Utils::CountItems::Master'); -const prometheusPollingPeriod = Number.parseInt(process.env.PROMETHEUS_POLLING_PERIOD, 10) > 0 - ? Number.parseInt(process.env.PROMETHEUS_POLLING_PERIOD, 10) - : 30; +function tryParseInt(s, defaultValue) { + const v = Number.parseInt(s, 10); + return v > 0 ? v : defaultValue; +} -const prometheusPollingAttempts = Number.parseInt(process.env.PROMETHEUS_POLLING_ATTEMPTS, 10) > 0 - ? Number.parseInt(process.env.PROMETHEUS_POLLING_ATTEMPTS, 10) - : 5; +const prometheusPollingPeriod = tryParseInt(process.env.PROMETHEUS_POLLING_PERIOD, 30); + +const prometheusPollingAttempts = tryParseInt(process.env.PROMETHEUS_POLLING_ATTEMPTS, 5); const numWorkers = process.env.NUM_WORKERS && !Number.isNaN(process.env.NUM_WORKERS) ? Number.parseInt(process.env.NUM_WORKERS, 10)