bullmq - v5.64.0
    Preparing search index...

    Class FlowProducer

    This class allows to add jobs with dependencies between them in such a way that it is possible to build complex flows. Note: A flow is a tree-like structure of jobs that depend on each other. Whenever the children of a given parent are completed, the parent will be processed, being able to access the children's result data. All Jobs can be in different queues, either children or parents,

    Hierarchy

    • EventEmitter
      • FlowProducer
    Index

    Constructors

    Properties

    closing: Promise<void>
    keys: KeysMap
    opts: QueueBaseOptions = ...
    queueKeys: QueueKeys
    toKey: (name: string, type: string) => string

    Accessors

    Methods

    • Adds a flow.

      This call would be atomic, either it fails and no jobs will be added to the queues, or it succeeds and all jobs will be added.

      Parameters

      • flow: FlowJob

        an object with a tree-like structure where children jobs will be processed before their parents.

      • Optionalopts: FlowOpts

        options that will be applied to the flow object.

      Returns Promise<JobNode>

    • Adds multiple flows.

      A flow is a tree-like structure of jobs that depend on each other. Whenever the children of a given parent are completed, the parent will be processed, being able to access the children's result data.

      All Jobs can be in different queues, either children or parents, however this call would be atomic, either it fails and no jobs will be added to the queues, or it succeeds and all jobs will be added.

      Parameters

      • flows: FlowJob[]

        an array of objects with a tree-like structure where children jobs will be processed before their parents.

      Returns Promise<JobNode[]>

    • Closes the connection and returns a promise that resolves when the connection is closed.

      Returns Promise<void>

    • Synchronously calls each of the listeners registered for the event namedeventName, in the order they were registered, passing the supplied arguments to each.

      Returns true if the event had listeners, false otherwise.

      import EventEmitter from 'node:events';
      const myEmitter = new EventEmitter();

      // First listener
      myEmitter.on('event', function firstListener() {
      console.log('Helloooo! first listener');
      });
      // Second listener
      myEmitter.on('event', function secondListener(arg1, arg2) {
      console.log(`event with parameters ${arg1}, ${arg2} in second listener`);
      });
      // Third listener
      myEmitter.on('event', function thirdListener(...args) {
      const parameters = args.join(', ');
      console.log(`event with parameters ${parameters} in third listener`);
      });

      console.log(myEmitter.listeners('event'));

      myEmitter.emit('event', 1, 2, 3, 4, 5);

      // Prints:
      // [
      // [Function: firstListener],
      // [Function: secondListener],
      // [Function: thirdListener]
      // ]
      // Helloooo! first listener
      // event with parameters 1, 2 in second listener
      // event with parameters 1, 2, 3, 4, 5 in third listener

      Type Parameters

      Parameters

      Returns boolean

      v0.1.26

    • Adds the listener function to the end of the listeners array for the event named eventName. No checks are made to see if the listener has already been added. Multiple calls passing the same combination of eventName and listener will result in the listener being added, and called, multiple times.

      server.on('connection', (stream) => {
      console.log('someone connected!');
      });

      Returns a reference to the EventEmitter, so that calls can be chained.

      By default, event listeners are invoked in the order they are added. Theemitter.prependListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

      const myEE = new EventEmitter();
      myEE.on('foo', () => console.log('a'));
      myEE.prependListener('foo', () => console.log('b'));
      myEE.emit('foo');
      // Prints:
      // b
      // a

      Type Parameters

      Parameters

      Returns this

      v0.1.101

    • Adds a one-timelistener function for the event named eventName. The next time eventName is triggered, this listener is removed and then invoked.

      server.once('connection', (stream) => {
      console.log('Ah, we have our first user!');
      });

      Returns a reference to the EventEmitter, so that calls can be chained.

      By default, event listeners are invoked in the order they are added. Theemitter.prependOnceListener() method can be used as an alternative to add the event listener to the beginning of the listeners array.

      const myEE = new EventEmitter();
      myEE.once('foo', () => console.log('a'));
      myEE.prependOnceListener('foo', () => console.log('b'));
      myEE.emit('foo');
      // Prints:
      // b
      // a

      Type Parameters

      Parameters

      Returns this

      v0.3.0