|
|
@ -11,6 +11,8 @@ const buffer = require("@promistream/buffer");
|
|
|
|
const pipe = require("@promistream/pipe");
|
|
|
|
const pipe = require("@promistream/pipe");
|
|
|
|
|
|
|
|
|
|
|
|
const createMutationAPIWrapper = require("./mutation-api/wrapper");
|
|
|
|
const createMutationAPIWrapper = require("./mutation-api/wrapper");
|
|
|
|
|
|
|
|
const logStatus = require("./log-status");
|
|
|
|
|
|
|
|
const chalk = require("chalk");
|
|
|
|
|
|
|
|
|
|
|
|
// FIXME: Revert inlining of task_states once switched to PostgreSQL 12+, which can do this automatically using NOT MATERIALIZED
|
|
|
|
// FIXME: Revert inlining of task_states once switched to PostgreSQL 12+, which can do this automatically using NOT MATERIALIZED
|
|
|
|
let query = `
|
|
|
|
let query = `
|
|
|
@ -128,7 +130,7 @@ module.exports = function (state) {
|
|
|
|
buffer(),
|
|
|
|
buffer(),
|
|
|
|
globalRateLimiter,
|
|
|
|
globalRateLimiter,
|
|
|
|
processTaskSafely(task, (item, tx) => {
|
|
|
|
processTaskSafely(task, (item, tx) => {
|
|
|
|
console.log(`[${task}][started] ${item.id}`);
|
|
|
|
logStatus(task, chalk.bold.cyan, "started", item.id);
|
|
|
|
|
|
|
|
|
|
|
|
let context = { tx, item, task, taskVersion };
|
|
|
|
let context = { tx, item, task, taskVersion };
|
|
|
|
|
|
|
|
|
|
|
@ -171,7 +173,7 @@ module.exports = function (state) {
|
|
|
|
expires_at: dateFns.add(new Date(), { seconds: ttlInSeconds })
|
|
|
|
expires_at: dateFns.add(new Date(), { seconds: ttlInSeconds })
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}).catch((error) => {
|
|
|
|
}).catch((error) => {
|
|
|
|
console.warn(`[${task}][failed] ${item.id}`, error);
|
|
|
|
logStatus(task, chalk.bold.red, "failed", item.id);
|
|
|
|
|
|
|
|
|
|
|
|
return Promise.try(() => {
|
|
|
|
return Promise.try(() => {
|
|
|
|
// Task failed -- note, cannot use tx here because it has failed
|
|
|
|
// Task failed -- note, cannot use tx here because it has failed
|
|
|
|