Probe.json constructor
- StackRun run
The command prints one JSON object on stdout:
{
"state": "up",
"detail": "slot 8200-8208 · 4 containers",
"services": [{"name": "postgres", "port": 8200, "state": "up"}]
}
state is one of down, starting, up, stopping, unavailable;
everything else is optional. failure is read too, and is where the
reason goes when the state is unavailable — though a detail is taken
as the reason there as well, because one sentence explaining what is wrong
is one sentence whichever key it arrives under.
A partly-up stack is up, with services saying which parts are
not. Four of five services serving fits no single word above, and the
word is not asked to carry it: report each service's own state and the
surfaces render the fraction — up 3/4, washed amber rather than
green. A probe that answers down there paints a working stack red and
buries the whole truth in detail; unavailable is wrong twice, since
it means the probe failed and this one just delivered its most useful
answer.
Read from stdout only. Almost nothing that prints structured output
has stderr to itself — dart announces Running build hooks... there,
docker writes deprecation warnings, a wrapper's set -x writes every line
it runs — so folding it in would make a probe that works for a fortnight
and then fails because a tool started mentioning something.
Output that does not parse is reported as unavailable quoting whatever
the command did say, because a probe that cannot be read is a probe that
failed — not a stack that is down.
Implementation
const Probe.json(this.run) : shape = ProbeShape.json;