Expand description
Cron schedule math: expression parsing, next-fire, and due-check.
chrono is confined to THIS module. Every public function takes and
returns SystemTime, so CronEntry, the scheduler, and the rest of
forge never touch chrono - the SystemTime <-> chrono conversion
happens only inside next_fire_afterβs private timezone helper.
Timezone: recurring expressions evaluate in the hostβs LOCAL time
(standard cron / crontab semantics). The public next_fire_after
hard-codes Local; the generic _in_tz helper it delegates to lets
tests pin a fixed offset and stay deterministic (CI runs UTC).
due_crons needs no TZ - a SystemTime is an absolute instant, so
the due-check is TZ-independent.
Re-exportsΒ§
use std::time::SystemTime;πuse chrono::DateTime;πuse chrono::Local;πuse chrono::TimeZone;πuse chrono::Utc;πuse croner::Cron;πuse croner::errors::CronError;πuse croner::parser::CronParser;πuse forge_primitives::cron::CronEntry;πuse forge_primitives::cron::CronId;πuse forge_primitives::cron::CronKind;π
FunctionsΒ§
- due_
crons π - The crons whose
next_fireis at or beforenow- the schedulerβs per-tick due set, in input order. Boot catch-up is just one such tick (Workspace::fire_due_cronsat startup): an overdue cron is due, so it fires once andadvance_or_remove_cronmovesnext_firepast every missed slot - catch-up-once falls out of the normal fire path, no separate boot reconcile needed. - next_
fire_ after - The next fire for a cron
kindstrictly afterafter, evaluated in the hostβs LOCAL timezone.Nonefor a run-once whose instant has passed, or a recurring expression that fails to parse / has no upcoming occurrence. - next_
fire_ πafter_ in_ tz - TZ-generic core of
next_fire_after. Split out so tests inject a fixed offset (deterministic regardless of the host TZ) while prod passesLocal. - next_
recurring_ πfire_ in_ tz - Next occurrence of cron
exprstrictly afterafter, intz. The sole SystemTime <-> chrono boundary:afterconverts in, the result converts back out, and chrono never escapes. - parse_
cron π - Parses with
sloppy_ranges, which takes the shorthand step syntax (5/5 * * * *) a registered schedule may already carry; the strict default rejects it, and a schedule that stops parsing is dropped. - validate_
cron_ πexpr - Validate a 5-field cron expression, returning a human-readable error
on failure.
cron__createcalls this to reject a malformed schedule at registration time with a clear message.