Skip to content

Commit

Permalink
250ms delay if continued=false
Browse files Browse the repository at this point in the history
  • Loading branch information
abaevbog committed May 8, 2023
1 parent ed5bf61 commit 2242052
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 2 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: ''
Expand Down
2 changes: 1 addition & 1 deletion config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"redis": {
"prefix": ""
},
"continuedDelayDefault": 0
"defaultDelay": 0
}
13 changes: 9 additions & 4 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}
}

/**
Expand Down

0 comments on commit 2242052

Please sign in to comment.