Class: FlowProducer
Defined in: glide-mq/src/flow-producer.ts:43
Creates parent-child job flows and DAG workflows. Children are processed first; the parent runs after all children complete.
Constructors
Constructor
new FlowProducer(opts): FlowProducer;Defined in: glide-mq/src/flow-producer.ts:51
Parameters
| Parameter | Type |
|---|---|
opts | FlowProducerOptions |
Returns
FlowProducer
Methods
add()
add(flow, flowOpts?): Promise<JobNode>;Defined in: glide-mq/src/flow-producer.ts:112
Add a flow (parent with children) atomically. Children can have their own children (recursive flows), which are flattened into multiple addFlow calls (one per level with children). In cluster mode, leaf children in a different queue than their parent are created first and then wired to the parent, since their keys live on another slot.
When flowOpts.budget is provided, a budget hash is created in Valkey and a budgetKey field is written to the parent and all child job hashes. Workers check this key before processing and after completion to enforce token and cost caps across the entire flow.
Parameters
| Parameter | Type |
|---|---|
flow | FlowJob |
flowOpts? | { budget?: BudgetOptions; } |
flowOpts.budget? | BudgetOptions |
Returns
Promise<JobNode>
addBulk()
addBulk(flows): Promise<JobNode[]>;Defined in: glide-mq/src/flow-producer.ts:223
Add multiple independent flows.
Parameters
| Parameter | Type |
|---|---|
flows | FlowJob[] |
Returns
Promise<JobNode[]>
addDAG()
addDAG(dag): Promise<Map<string, Job<any, any>>>;Defined in: glide-mq/src/flow-producer.ts:536
Add a DAG (Directed Acyclic Graph) flow where jobs can have multiple parents. Validates the graph for cycles, performs topological sort, and submits nodes bottom-up (leaves first). For nodes with multiple parents, registers each parent dependency.
Submission is pipelined by topological level: within a level, all primary FCALLs are sent in one Batch (non-atomic pipeline), then a child-slot batch persists parent metadata and cross-queue parent references. Same-queue registerParent calls and cross-queue parent notifications are completed after that batch. Before the leaf level is added, every leaf is put in its dependents' deps sets (auto ids are reserved first), so no leaf completion can release a parent while a sibling dependency is unregistered. RTT is O(levels) plus two for that pre-registration and cross-slot wiring.
Returns a map of node name to Job instance.
Parameters
| Parameter | Type |
|---|---|
dag | DAGFlow |
Returns
Promise<Map<string, Job<any, any>>>
close()
close(): Promise<void>;Defined in: glide-mq/src/flow-producer.ts:1074
Close the FlowProducer and release the underlying client connection. Idempotent: safe to call multiple times.
Returns
Promise<void>