Skip to main content

Overview

The FlowProducer class allows you to add jobs with dependencies between them in a tree-like structure called a flow. Whenever the children of a given parent are completed, the parent will be processed.

Constructor

QueueBaseOptions
Configuration options for the flow producer

Example

Methods

add

Adds a flow (tree of jobs) to the queue.
FlowJob
required
An object with a tree-like structure where children jobs will be processed before their parents
FlowOpts
Options that will be applied to the flow
JobNode
The job tree structure with created job instances

FlowJob Structure

addBulk

Adds multiple flows atomically.
FlowJob[]
required
An array of flow objects
JobNode[]
Array of job tree structures with created job instances

getFlow

Retrieves a flow by its root job.
NodeOpts
required
Options for getting a flow

NodeOpts

close

Closes the connection.

disconnect

Force disconnects the connection.

Flow Concepts

Job Dependencies

In a flow, jobs can have parent-child relationships:
  • Child jobs are processed first
  • Parent jobs wait for all children to complete
  • Parent jobs can access children’s return values

Cross-Queue Flows

Jobs in a flow can be in different queues:

Nested Dependencies

Flows can be nested to create complex dependency trees:

JobNode Type

Events

The FlowProducer class extends EventEmitter and emits the following events:

error

Emitted when an error occurs.