YmerNode.Schedules.LastRun (Ymer Node v0.4.0)

Copy Markdown View Source

What a schedule's row keeps of its last run: the moment the firing that started it came due, one of four outcomes, the runner's own message, and how long the run took. Nothing before it — there is no run history, and a skipped firing leaves no trace — because the node is a script runner, not a reliable scheduler. What a script produces goes where the script puts it; anything it wants kept beyond one line, it writes to the notebook.

The outcome answers "did it work, and whose move is it" in one word, grouping the reasons YmerNode.Scripts.Runner tabulates:

outcomereasonswhose move
ok—nobody's
refused:not_found, :not_accepted, :not_loaded, :unknown_action, :invalid_schema, :invalid_argsthe run never started: fix the schedule, or accept the script
error:script_error, :script_raised, :script_exited, :bad_return, :result_not_encodablethe script ran and failed: fix the script
timeout:timeoutthe run passed its deadline and was killed

:not_found is the one reason that is not the runner's: the script's row gone between a firing and its run. A script's schedules are deleted with it, so only that window can see it.

The message is the runner's rendered text, cut short at a fixed length: it is a line to read in a listing, not a log.

Summary

Functions

The row's last-run fields for one run's answer.

The outcome one run's answer is recorded as.

Functions

attrs(result, fired_at, took_ms)

The row's last-run fields for one run's answer.

Examples

iex> YmerNode.Schedules.LastRun.attrs({:ok, %{"pong" => true}}, ~U[2026-09-26 07:00:00Z], 12)
%{last_fired_at: ~U[2026-09-26 07:00:00Z], last_outcome: "ok", last_message: nil, last_run_ms: 12}

iex> YmerNode.Schedules.LastRun.attrs({:error, {:timeout, "hex fetch: no answer in 30000 ms, run killed"}}, ~U[2026-09-26 07:00:00Z], 30_001)
%{last_fired_at: ~U[2026-09-26 07:00:00Z], last_outcome: "timeout", last_message: "hex fetch: no answer in 30000 ms, run killed", last_run_ms: 30_001}

outcome(arg)

The outcome one run's answer is recorded as.

Examples

iex> YmerNode.Schedules.LastRun.outcome({:error, {:not_accepted, "hex is not accepted"}})
"refused"

iex> YmerNode.Schedules.LastRun.outcome({:error, {:script_raised, "hex fetch: boom"}})
"error"