Composable Orchestration Patterns

Build orchestration from a small set of named, reusable primitives — sequences, conditionals, fan-outs, and loops — rather than writing bespoke control flow for every workflow.

What it is

Orchestration logic has a tendency to grow into unmaintainable procedural code: if-else trees nested inside loops inside callbacks, with workflow state threaded through as mutable variables. The alternative is to build from a small set of named orchestration primitives — sequence, conditional, fan-out, fan-in, loop, gate — and express any workflow as a composition of these patterns rather than as custom logic. A sequence runs steps in order. A conditional branches based on the output of a preceding step. A fan-out spawns parallel workers. A fan-in waits for parallel workers to complete and aggregates their results. A loop runs a step repeatedly until a condition is met. A gate waits for human approval before proceeding. These are not special-purpose constructs — they are the vocabulary of orchestration. Any workflow can be expressed as a tree of these patterns, and a workflow expressed this way can be read, modified, and debugged by anyone who knows the vocabulary. It can also be tested by substituting a pattern implementation with a test double, because each primitive is isolated from the others. When orchestration is instead written as bespoke procedural code, every new workflow is a new language and every debugging session requires understanding that language from scratch.

When to reach for it

When NOT to

Exemplars

Related