Reference · Requests and pages
ready
ready(str, fn) -> nullWhat it does
Adds a check of the program's own to GET /_quillo/ready, which answers 200 when
everything the program needs is there and 503 when not, with each part as JSON: its
database (select 1), each service it declares, and the checks added here. The
function is called for each probe and holds when it gives true. Each part is said
only to a request with the health token (Authorization: Bearer and
QUILLO_HEALTH_TOKEN, 16 characters at least); anyone else gets {"ready": true} or
{"ready": false} (since 0.7: each part, services' addresses among them, to anyone).
For an orchestrator's readiness probe. It gives null.
Examples
ready("ledger", () => len(accounts.problems() ?? ["down"]) == 0)ready("uploads", () => len(read_file("uploads/.ok") ?? "") > 0)curl -i localhost:8080/_quillo/ready# {"ready": false}curl -i localhost:8080/_quillo/ready -H "Authorization: Bearer $QUILLO_HEALTH_TOKEN"# {"ready": false, "checks": {"database": "ready", "ledger": "ready", "uploads": "not ready"}}print(ready("ledger", () => true))nullEdge cases
- A check that gives anything but
true, or fails, counts as not ready: a check written aslen(problems()) == 0gives a boolean, which is what is wanted. - Adding a check with the name of an earlier one replaces it.
/_quillo/healthis not affected: it says only whether the process is up. Neither request is logged or counted.- Under a mount or
--base(thequillo runoption that serves the program under a path:quillo run main.qwe --base /shop; see the options),/shop/_quillo/readyasks the mounted program. - In a plain program the function is never called: nothing probes it.
print(ready("ledger", () => false), ready("ledger", () => true))null nullErrors
A name that is not a string, or a second argument that is not a function, is a runtime error, not an error value. Both are required.
ready("ledger")line 1: `ready` takes a name and a function that says whether it holds: ready("ledger", () => ...)Chaining
It stands at the top of the program, once per check. The function may be one of the program's own by name:
fn ledger_ok() = trueprint(ready("ledger", ledger_ok))nullSee also
schedule, db.query, allow_cross_site
Thread 0 posts
On ready(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo