Log inStart free
LESSON 23.12 · 5 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Checkpoints and resumable workflows

Eight payments survive a crash and a slow approval with a journal of checkpoints.


Pro lesson. Stage 1 is free to watch. Pro opens all 5 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 23.12 · WORKFLOW BAY8 PAYMENTS · 10 STEPS · 11 CALLS
01
Stage 1 of 5 · State machine
A workflow pays the 8 payments in order. Each payment is a state machine: events move it between states.
Explain it simply

The workflow is a loop over the 8 payments, one at a time. Each payment sits in one state, a box on the chart. An event, such as an ok reply, moves it along one arrow. A solid arrow was used in this run; a dashed arrow was not.

A chart of seven states: queued, approval, charging, paid, rejected, expired and failed. Below it, worker 1 runs 10 steps. That is a charge for each paid payment, plus the ask and the answer for payment 5.

steps run livejournal and waitscrashes and errorsok and chargesdashed: replay, wait, unused, by service
its turnover $50yesno60 minfail: retryok4 failsqueued · 8approval · 1charging · 8paid · 8rejected · 0expired · 0failed · 0charge 1charge 2charge 3charge 4ask 5answer 5charge 5charge 6charge 7charge 8worker 1from 9:00card chargesokokokoksentapproved40 minokokokokstate machine of one paymentδ(queued, over $50) = approval8 of 8 end in paidits turnover $50yesno60 minfail: retryok4 failsqueued · 8approval · 1charging · 8paid · 8rejected · 0expired · 0failed · 0charge 1charge 2charge 3charge 4ask 5answer 5charge 5charge 6charge 7charge 8worker 1from 9:00card chargesokokokoksentapproved40 minokokokokstate machine of one paymentδ(queued, over $50) = approval8 of 8 end in paid
Toy: 8 payments one at a time · a tool that fails 30% of calls · payment 5 needs a person
STAGE 1 / 5
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
st+1=δ(st, et)\sy{s}{data}{s_{t+1}} = \delta(\sy{s}{data}{s_t},\ \sy{e}{data}{e_t})
δ(queued, over $50)=approval\delta(\text{queued},\ \text{over } \$50) = \text{approval}

The next state depends only on the state now and the event.

Common mix-ups

MYTHWith checkpoints, a step never runs twice.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01Checkpoints off, crash after payment 7, approver approves: how many payments are charged twice?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 5
Unlock the full explainer
  • 4 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.