jonnifyechomq

The Queue · module 05

Flows — orchestration over the queue

A parent job and a list of children. The children run; the parent runs only after they finish.

A flow composes dependent work: a parent job and a flat list of children. The children are written claimable; the parent is held out of the pending set with an outstanding-child counter at :dependencies and its row state = awaiting_children. One atomic script lands a same-queue flow on one slot; the fan-in inside @complete decrements the counter as children finish and, at zero, releases the parent to pending. Composition is a counter and one atomic script — not a coordinator. This module reads the shape, the three result reads, and the cross-queue path.

Three scripts carry a flow

A same-queue flow lands in one atomic script. A cross-queue flow lands parent-first across two more. The fan-in that releases the parent is the single-queue branch already inside @complete. Pick a script to read its handle, the keys it declares, and the transition it performs — the catalog is the protocol.

The flow script catalog · pick a script

parent · held (awaiting_children) :dependencies = N child · pendingclaimable child · pendingclaimable child · pendingclaimable fan-in: DECR :dependencies → at 0, release parent

A flow is a held parent, claimable children, and a counter. Land it atomically; release it on the fan-in. There is no coordinator in the loop.

The dives

Three dives read flows in depth, each grounded in real echo/apps/echo_mq code: the shape and the atomic same-queue add, the three pure reads the parent runs on, and the cross-queue path with its failure policy.

built page ready to read

Pattern & implementation

Where Redis Patterns Applied teaches composing dependent work, this module is where the move lands. The flow is a counter and one atomic script.

the pattern (Redis Patterns Applied)

Orchestrating dependent work — a parent step that waits on its legs — is the flow-control angle, R6 · Flow control. The near, resolvable door is R3 · Reliable Queues: each child is one reliable-queue job the flow composes.

the implementation (echo_mq)

EchoMQ.Flows.add/3 lands the held parent + the claimable children in one @enqueue_flow; the parent's :dependencies counter holds it; the fan-in branch inside EchoMQ.Jobs @complete decrements and at zero releases it.

Take the dives in order, or jump to the cross-queue path if you already know the same-queue shape. The module names R6 · Flow control as its pattern; the resolvable door is Reliable Queues.

References

Sources

Related in this course