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