Flow shapes
Each shape is made from single runs. Your own workflow tool, cron job or queue, or the caller, starts the runs and keeps the state. A run never starts other runs.
Which one to use
| Shape | Who does it | Plan | Use it when | Read |
|---|---|---|---|---|
| 1 · Fan-out | Your orchestrator or a script starts many runs. | Any plan | Work splits into parts that can run at the same time. | Fan-out |
| 2 · Fan-in | Your orchestrator waits for all parts, then combines the results. | Any plan | The next step needs every part. | Fan-in |
| 3 · Branch and loop | The task returns the next step or "again". The caller starts it and counts. | Any plan | The next step depends on a result. | Branch and loop |
| 4 · One at a time | Your orchestrator, a schedule, or a bidirectional task. | Any plan. A schedule needs a plan with schedules; the bidirectional way needs Starter and up. | Runs must not overlap. | One at a time |
1 · Fan-out
Use it when work splits into parts. Your orchestrator or a script starts one run for each part, at the same time.
Plan: any plan.
- Start each part with its own idempotency key: the flow id and the part number.
- Your plan limits the runs that run at the same time. Above it, a start is refused with
429andRetry-After; waiting in a queue does not help. Start a few parts at a time, and the next when one ends. - Put the flow id and the part number in each payload.
2 · Fan-in
Use it when the next step needs every part. Your orchestrator keeps the run ids it started. It waits until each run has ended, then combines the results. The diagram above shows both.
Plan: any plan.
- Wait with
run:getfrom time to time, or with a callback to your own receiver. - A large part goes to your own database under the flow id. The result holds only a reference.
- Decide what one failed part means: try that part again with a new key, or fail the flow.
3 · Branch and loop
Use it when the next step depends on a result. The task returns which step comes next, or "again". The caller starts that step. For a loop, the caller counts and stops at a maximum.
Plan: any plan.
- Keep the count in the caller, or in the payload. Do not keep it only in the memory of a warm VM: you can lose it.
- Set a maximum. A loop with no maximum can run, and cost, forever.
4 · One at a time
Use it when runs must not overlap. Pick one of three ways.
- Your orchestrator starts the next run only after the last one ended. Any plan.
- A schedule skips a slot while its last run is still active (
overlap: skip, the default). A plan with schedules. See Run on a schedule. - A bidirectional task runs one run at a time on one VM. With
on_busy: queue, a second run waits and then runs on the same VM. Withstate: across-runs, the runs share its memory. Plan: Starter and up, because the task serves inbound traffic.