Waiting gets its own station
Some work can't go on until someone outside the line acts: a manager approves an invoice, a customer replies, another system finishes its part. Nothing is broken. The workpiece just has to wait, possibly for days. Give the waiting a station of its own.
IN1 check ──▶ output/needs_approval/ ──▶ INW waits for approval ──▶ output/approved/ ──▶ IN2 post
└─▶ output/rejected/
Waiting is not failing
| Failed | Waiting | |
|---|---|---|
| Means | The station tried and couldn't finish | Nothing is wrong; someone outside the line hasn't acted yet |
| Sits in | failed/, with the error | The waiting station's input/ |
| Cleared by | A person fixes the cause and sends it back | The outside party acts; the next check releases it |
| Lasts | Until someone looks | Hours to weeks |
A wait never goes to failed/. It would bury the work that is waiting among the work that is broken, and a retry would only find it still waiting. See Nothing leaves silently.
Why a station of its own
Where a workpiece sits is its state. An invoice left in IN2/input/ says "IN2 hasn't got to this yet", which is false: IN2 can't post it until it's approved. So:
- A working station's
input/would lie. Waiting work looks exactly like work that station never started. - Its counts would lie too. Work that has waited a week looks like a backlog at the station.
- Not
doing/either.doing/is cleared when the line restarts (The doing bin), so a held workpiece would be lost.
In the waiting station's own input/, "held here and checked again" is exactly what the bin means.
How it runs
On each run, the waiting station checks every workpiece in its input/:
- Decided: it records the decision in the workpiece and files it into the lane for that decision:
output/approved/,output/rejected/. Each next station pulls its own lane. - Not decided yet: it leaves the workpiece in
input/and checks it again next run. - The outside system can't be reached: it holds the workpiece and says so in the run report. Nothing about the workpiece is wrong.
- The workpiece itself is broken, such as a file the check needs is missing: that is a real failure, and it goes to
failed/.
The run report shows how many were released into each lane and how many are still waiting.
Run it on a timer, not when work arrives. Held work keeps the station's input/ full, so a trigger that fires whenever input/ has work would run it again every few seconds. Check as often as the decision needs: hourly is plenty for a person.
The station that asks is not the station that waits
Asking (creating the approval request, emailing the person) is an action with an outside effect. Do it in a station before the waiting station. Each workpiece passes that station once, so the person is asked once. The waiting station only reads the answer, so checking a hundred times never sends a second email.
Related
- Act towards a goal state: when a precondition isn't met, hold the work or let a later run bring it back
- Hold a workpiece until someone decides: building a waiting station with lib-factory
- Bins: sub-bins in
output/as lanes for the next stations