Skip to content

Function: dag()

ts
function dag(
   nodes, 
   connection, 
prefix?): Promise<Map&lt;string, Job&lt;any, any>>>;

Defined in: glide-mq/src/workflows.ts:165

DAG: submit a directed acyclic graph of jobs where each job can depend on multiple other jobs. The graph is validated for cycles and submitted in topological order (leaves first).

Returns a Map of node name to Job instance.

Example - diamond dependency:

const jobs = await dag([
  { name: 'A', queueName: 'q', data: {}, deps: [] },
  { name: 'B', queueName: 'q', data: {}, deps: ['A'] },
  { name: 'C', queueName: 'q', data: {}, deps: ['A'] },
  { name: 'D', queueName: 'q', data: {}, deps: ['B', 'C'] },
], connection);

Parameters

ParameterType
nodesDAGNode[]
connectionConnectionOptions
prefix?string

Returns

Promise<Map<string, Job<any, any>>>

Released under the Apache-2.0 License.