From 2242052e160ce6f3653edb7e1a8db4df39c71ca7 Mon Sep 17 00:00:00 2001 From: Bogdan Abaev Date: Mon, 8 May 2023 17:16:38 -0400 Subject: [PATCH 1/2] 250ms delay if continued=false --- config/default.js | 3 ++- config/test.json | 2 +- server.js | 13 +++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/config/default.js b/config/default.js index 7e82b22..b23a4f7 100644 --- a/config/default.js +++ b/config/default.js @@ -30,7 +30,8 @@ var config = { // Notification action period -- clients are given a randomly chosen delay within this time // period before they should act upon the notification, so that we don't DDoS ourselves globalTopicsDelayPeriod: 1800 * 1000, - continuedDelayDefault: 3 * 1000, + notContinuedDelay: 250, + defaultDelay: 3 * 1000, continuedDelay: 30 * 1000, statsD: { host: '' diff --git a/config/test.json b/config/test.json index 63ea8e3..90105fc 100644 --- a/config/test.json +++ b/config/test.json @@ -4,5 +4,5 @@ "redis": { "prefix": "" }, - "continuedDelayDefault": 0 + "defaultDelay": 0 } diff --git a/server.js b/server.js index 70f772e..c7a4e93 100644 --- a/server.js +++ b/server.js @@ -60,10 +60,15 @@ module.exports = function (onInit) { clearTimeout(timeout); delete continuedTimeouts[topic]; } - - continuedTimeouts[topic] = setTimeout(fn, - continued ? config.get('continuedDelay') : config.get('continuedDelayDefault') - ); + if (continued) { + continuedTimeouts[topic] = setTimeout(fn, config.get('continuedDelay')); + } + else if (continued == false) { + continuedTimeouts[topic] = setTimeout(fn, config.get('notContinuedDelay')); + } + else { + continuedTimeouts[topic] = setTimeout(fn, config.get('defaultDelay')); + } } /** From 083dc490c518098c6c000e13efba8a9f7702aef4 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 9 May 2023 04:29:29 -0400 Subject: [PATCH 2/2] Tweak order of delay parameters --- config/default.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/default.js b/config/default.js index b23a4f7..010c977 100644 --- a/config/default.js +++ b/config/default.js @@ -30,9 +30,9 @@ var config = { // Notification action period -- clients are given a randomly chosen delay within this time // period before they should act upon the notification, so that we don't DDoS ourselves globalTopicsDelayPeriod: 1800 * 1000, - notContinuedDelay: 250, defaultDelay: 3 * 1000, continuedDelay: 30 * 1000, + notContinuedDelay: 250, statsD: { host: '' }