Workflow Examples
Three runnable workflows in the examples repository cover the full state-type palette.
Each directory has the workflow.yaml, the functions it calls, and sample inputs, plus a README with the deploy steps.
Read them alongside the authoring reference.
Order pipeline — Parallel, Choice, retry, catch
An e-commerce checkout: validate an order, then screen it for fraud and stock in parallel.
A Choice routes on the results.
Charging the card includes retry and a catch for declines.
Every failure converges onto one rejection path.
It is the flagship example — the one the stateDiagram on the overview page is drawn from.
- Shows:
Parallelwith an ordered join, data-drivenChoice,Taskretryfor transient gateway errors, andcatchon a typedPaymentDeclinederror. - Inputs:
happy,invalid,high-fraud,out-of-stock,declined-card,flaky-gateway— one per route through the machine. - order-pipeline →
Batch enrichment — Map fan-out
Enrich a batch of CRM leads: a Map state invokes a single-record scoring function once per element of $.leads, at most three concurrently.
The ordered join array feeds a summary step.
The function stays simple.
The workflow owns the fan-out, throttling, retries, and ordering.
- Shows:
MapwithitemsPathandmaxConcurrency, and an ordered join feeding the nextTask. - Inputs:
leads— the array the Map iterates. - batch-enrichment →
Payment dunning — durable Wait timers
Subscription renewal with a grace period: if a charge is declined, the run waits out a grace period on a durable timer. It tries once more before canceling. The run consumes no pod, memory, or connection while waiting — the timer lives in the statestore and survives controller restarts.
- Shows:
Waitas a durable delay, and acatchroute that changes behavior on the second attempt. - Inputs:
valid,past-due— one that charges cleanly, one that exercises the grace-period retry. - payment-dunning →
Related
- Authoring workflows — the fields these examples use.
- Run and inspect — run them and trace where each input lands.