|
|
@ -143,7 +143,8 @@ module.exports = function ({ metrics, backendSettings, knex }) {
|
|
|
|
}).then((newItems) => {
|
|
|
|
}).then((newItems) => {
|
|
|
|
if (newItems === 0) {
|
|
|
|
if (newItems === 0) {
|
|
|
|
// TODO: Consider using LISTEN/NOTIFY instead? Worth the added complexity?
|
|
|
|
// 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 {
|
|
|
|
} else {
|
|
|
|
// Have another go right away
|
|
|
|
// Have another go right away
|
|
|
|
return [];
|
|
|
|
return [];
|
|
|
|