|
|
|
@ -143,7 +143,8 @@ module.exports = function ({ metrics, backendSettings, knex }) {
|
|
|
|
|
}).then((newItems) => {
|
|
|
|
|
if (newItems === 0) {
|
|
|
|
|
// TODO: Consider using LISTEN/NOTIFY instead? Worth the added complexity?
|
|
|
|
|
return Promise.resolve([]).delay(backendSettings.taskBatchDelay);
|
|
|
|
|
let randomization = Math.random() * backendSettings.delayRandomization * backendSettings.taskBatchDelay; // To prevent stampeding by low-throughput tasks
|
|
|
|
|
return Promise.resolve([]).delay(backendSettings.taskBatchDelay + randomization);
|
|
|
|
|
} else {
|
|
|
|
|
// Have another go right away
|
|
|
|
|
return [];
|
|
|
|
|