UNPKG

@sidequest/core

Version:

@sidequest/core is the core package of SideQuest, a distributed background job queue for Node.js and TypeScript applications.

32 lines (28 loc) 1.02 kB
'use strict'; var logger = require('../logger.cjs'); var transition = require('./transition.cjs'); /** * Transition for marking a job as canceled. * * This transition sets the job state to "canceled" and records the * cancellation timestamp. Canceled jobs will not be retried or processed. * * Running jobs will be aborted, but this transition does not * stop jobs that are already claimed or running. It only marks them as canceled. * The engine will handle the actual stopping of running jobs. * * This transition can be applied to jobs in "waiting" or "running" states. */ class CancelTransition extends transition.JobTransition { apply(job) { logger.logger("Core").info(`Cancelling job #${job.id} - ${job.class}`); job.state = "canceled"; job.canceled_at = new Date(); return job; } shouldRun(job) { return ["waiting", "running"].includes(job.state); } } exports.CancelTransition = CancelTransition; //# sourceMappingURL=cancel-transition.cjs.map