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
  • Issues
  • #552
Closed
Open
Issue created May 28, 2017 by Administrator@rootContributor

[Feature] Job dependencies

Created by: ccollie

Let's say you have one job that depends on another, but the task definitions are fundamentally different. Consider the following example:

const debitAccount = await orderQueue.add('debitAccount', 
      {id : accountId, orderId: orderId, amount: costOfWidget});

const preparePackingSlip = await orderQueue.add('prepareShipment', 
      {id : accountId, orderId: orderId}, {depends : [debitAccount.id]);

// debitAccount.id not necessary here, but used to demonstrate that 
// we can have multiple dependencies
notificationQueue.add('notifyWidgetShipped', {orderId : orderId}, 
     {depends : [debitAccount.id, preparePackingSlip.id]});

Notifications are sent only after the packing slip job is completed.

We're considering using bull instead of our in-house solution, and this is one of the major missing features. I'd be willing to take the lead on this.

Implementation

Internally this would require a 'dependent' list in addition to 'delayed'. As a jobs are completed, their dependent lists are scanned and the id of the completed job is removed. Once the count of a child job's dependencies reaches 0, it's moved from the 'dependent' list to 'active'. If any of the parent jobs fail, the dependents are discarded recursively.

Assignee
Assign to
Time tracking