Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bull
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 175
    • Issues 175
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OptimalBits
  • bull
  • Merge requests
  • !2001

feat: expose repeatable queue functions

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Hugo Poissonnet requested to merge github/fork/Monibrand/feat/expose-queue-repeatable-functions into develop Mar 23, 2021
  • Overview 1
  • Commits 1
  • Pipelines 0
  • Changes 1
  • 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);
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/Monibrand/feat/expose-queue-repeatable-functions