UNPKG

@sidequest/core

Version:

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

31 lines (27 loc) 947 B
'use strict'; var logger = require('../logger.cjs'); var transition = require('./transition.cjs'); /** * Transition for marking a job as running. * * This transition sets the job state to "running", updates the attempted_at timestamp, * and increments the attempt count. * It is typically used when a job is claimed and starts execution. * * This transition should only be applied to jobs that are in the "claimed" state. * If the job is not in the "claimed" state, this transition will not run. */ class RunTransition extends transition.JobTransition { apply(job) { logger.logger("Core").info(`Running job #${job.id} - ${job.class}`); job.state = "running"; job.attempted_at = new Date(); job.attempt = job.attempt + 1; return job; } shouldRun(job) { return job.state === "claimed"; } } exports.RunTransition = RunTransition; //# sourceMappingURL=run-transition.cjs.map