@sidequest/core
Version:
@sidequest/core is the core package of SideQuest, a distributed background job queue for Node.js and TypeScript applications.
30 lines (27 loc) • 974 B
JavaScript
import { logger } from '../logger.js';
import { JobTransition } from './transition.js';
/**
* 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 JobTransition {
apply(job) {
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);
}
}
export { CancelTransition };
//# sourceMappingURL=cancel-transition.js.map