UNPKG

@grouparoo/core

Version:
30 lines (29 loc) 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CLSTask = void 0; const actionhero_1 = require("actionhero"); const apm_1 = require("../../modules/apm"); const cls_1 = require("../../modules/cls"); class CLSTask extends actionhero_1.Task { constructor() { super(); this.plugins = ["QueueLock"]; } async run(inputs, worker) { return apm_1.APM.wrap(this.name, "task", worker, async () => { try { return cls_1.CLS.wrap(async () => this.runWithinTransaction(inputs, worker), { write: true, }); } catch (err) { const message = ((err === null || err === void 0 ? void 0 : err.message) || "").toString(); if (message.match(/SQLITE_BUSY/)) { (0, actionhero_1.log)(`re-enqueue (${this.name}): ${message}`, "error"); return cls_1.CLS.enqueueTaskIn(30 * 1000, this.name, inputs, this.queue); } } }); } } exports.CLSTask = CLSTask;