- getNextMillis
- getRepeatJobId
- getRepeatKey
Use cases
custom getNextMillis
use at your own risk
queue = new Bull('randomIntervalQueue');
queue.getNextMillis = function(millis, opts) {
if (opts.cron) {
throw new Error(
'.cron options are not supported in this queue'
);
}
if (!opts.every) {
throw new Error(
'.every options must be provided in this queue'
);
}
return Math.floor(Math.floor(millis / opts.every) * opts.every + opts.every + Math.random() * opts.every);
};
getRepeatKey for removing repeatable job
const [job] = await queue.getRepeatableJobs();
const jobKey = queue.getRepeatKey(job.name, job.opts.repeat, job.opts.repeat.jobId + ':');
await queue.removeRepeatableByKey(jobKey);
getRepeatJobId for getting job
const [job] = await queue.getRepeatableJobs();
const jobId = queue.getRepeatJobId(job.name, job.id + ':', job.next, md5(job.key));
const fullJob = queue.getJob(jobId);