Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When continued variable is explicitly false, delay is set to be 250ms #29

Merged
merged 2 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +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,
continuedDelayDefault: 3 * 1000,
defaultDelay: 3 * 1000,
continuedDelay: 30 * 1000,
notContinuedDelay: 250,
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