job-states
One job changes state in place, from queued to running to failed, waits out a 2 s backoff, and succeeds on the second attempt, while a small state map lights the current state and the event log fills in.
Swipe sideways to see the whole figure.
- Verb
- switch
- Archetype
- states
- Domain
- software
- viewBox
- 1200 × 600
- Control
- once: plays one pass, then rests on the finished state
- Pass
- 9.8 s
- Technique
- one ticket outline whose stroke colour, dash and width switch at each cause, stacked status words and attempt counter cross-faded, a backoff timer arc drawn on once, map lights and log lines following 100 to 150 ms later
- Tags
- lifecycle, retry, state-machine, jobs, error-handling
- Files
- job-states.html (fragment) · job-states-demo.html (playable page) · spec.yaml · thumb.png
- Source
- pool/job-states/
Paste the fragment into any HTML deck; it plays while an ancestor has the
class visible (one pass for once, then it holds the finished state) and
otherwise shows its resting frame. Rename the prefix
(job-states) when you adapt it so it stays unique in your deck.
spec.yaml
# Job lifecycle with one failure, a retry and a success on the second attempt. Scaffold with:
# python3 scripts/scaffold_from_spec.py pool/job-states/spec.yaml -o pool/job-states/job-states.html
# job-states.html is hand-built beyond the scaffold (verb switch): one job ticket in the centre
# changes in place at each event (outline colour and dash, stacked status word, a backoff timer
# arc, "attempt 1 of 3" -> "attempt 2 of 3"), a small state map at the left lights the current
# state, and the event log fills in one line per transition. No token. The spec reproduces the
# states, transitions and phase timing only. The spec's notes are the log lines.
name: job-states
archetype: states
verb: switch
size: [1200, 600]
control: once
cycle: 9.8
nodes:
- { id: queued, label: Queued }
- { id: running, label: Running, sub: "attempt 1 of 3" }
- { id: done, label: Succeeded, kind: milestone }
- { id: failed, label: Failed }
edges:
- { from: queued, to: running, label: picked }
- { from: running, to: done, label: exit 0 }
- { from: running, to: failed, label: error, kind: event }
- { from: failed, to: queued, label: "retry · 2 s", kind: event }
phases:
- { t: 0, label: queued, active: [queued], note: "00:00 queued" }
- { t: 0.9, label: pick, active: [running], flow: ["queued>running"], note: "00:02 picked · attempt 1" }
- { t: 3.1, label: fail, active: [failed], flow: ["running>failed"], note: "00:31 error · timeout" }
- { t: 4.7, label: retry, active: [queued], flow: ["failed>queued"], note: "00:33 retry after 2 s" }
- { t: 5.9, label: repick, active: [running], flow: ["queued>running"], note: "00:35 picked · attempt 2" }
- { t: 7.6, label: success, active: [done], flow: ["running>done"], note: "00:58 exit 0 · succeeded" }
- { t: 8.7, label: hold, active: [done] }