Demonstrates dag() helper and FlowProducer.addDAG() for arbitrary dependency graphs with multi-parent fan-in, diamond patterns, and cycle detection.
- Diamond dependency - a node waits for two parents to complete before running
- Fan-in merge - multiple independent sources converge into a single merge step
- Topological sort - nodes submitted in correct dependency order automatically
- Cycle detection - invalid graphs are rejected before any jobs are created
- getChildrenValues() - parent nodes read results from all their dependencies
npm installRequires Valkey/Redis on localhost:6379.
npm start| Feature | flow.add() (tree) |
dag() / flow.addDAG() |
|---|---|---|
| Shape | Parent-child tree | Arbitrary DAG |
| Parents per node | Exactly 1 | 0 to N |
| Fan-in | Not possible | Native via deps array |
| Diamond pattern | Not possible | Supported |
| Cycle detection | N/A (trees are acyclic) | Automatic (throws CycleError) |
depslists the names of other nodes in the same DAG submission- Nodes with no
depsrun immediately (leaves) - A node only becomes runnable after ALL its deps complete
- The
dag()helper creates a temporary FlowProducer internally - For tree-shaped workflows,
flow.add()is simpler and equally efficient