Documentation
¶
Overview ¶
Package cronspec is muster's ONE cron grammar: the five-field UTC expression a builtin officer's schedule (internal/officers/builtin) and a scheduled host job (internal/hostjobs, docs/host-jobs.md) both take, so the two cannot disagree about what an expression means. A leaf of the standard library alone, so the host binary (muster-mirror) checks its own jobs file with it without linking the server's stores.
Index ¶
Constants ¶
const CustomWords = "On a custom timetable (UTC)"
CustomWords is Describe's answer for a timetable it does not put in words.
Variables ¶
This section is empty.
Functions ¶
func Describe ¶ added in v0.301.0
Describe is expr in plain words, for a person: "Weekdays at 09:00 UTC", "Every 15 minutes". It names only what it is sure of — a common shape it recognises exactly — and answers CustomWords for anything else (or for an expression Parse refuses), so a schedule is never described as something it is not. Times are UTC, as every cron here is, and say so.
Recognised, field by field (minute hour day-of-month month day-of-week):
- minute `*` or `*/n` with n dividing 60, every other field `*`: "Every minute" / "Every n minutes". A step that does not divide 60 (`*/7`) does NOT fire evenly across the hour (…:56, then :00), so it is custom.
- minute a number m, hour `*`: "Every hour, on the hour" / "Every hour at m minutes past".
- minute m, hour `*/n` with n dividing 24: "Every n hours from 00:mm UTC".
- minute m, hour h or a list h1,h2,…: "<days> at HH:MM UTC" (several: "at 09:00 and 17:00 UTC"); hour a range a-b: "<days>, every hour from HH:MM to HH:MM UTC".
- days: both day fields `*` "Every day"; day-of-week `1-5` "Weekdays", `0,6` / `6,0` / `6,7` "Weekends", one day "Mondays", a list "Mondays, Wednesdays and Fridays"; day-of-month one number n with day-of-week `*` "On the nth of every month". The month field must be `*`.
Types ¶
type Cron ¶
type Cron struct {
// contains filtered or unexported fields
}
Cron is a parsed five-field cron expression — minute hour day-of-month month day-of-week — evaluated in UTC. Each field takes `*`, a number, a range `a-b`, a list `a,b,c` and a step `*/n` or `a-b/n`; day-of-week is 0–6 with 0 (or 7) Sunday. When BOTH day fields are restricted a day matches if EITHER does; a field counts as unrestricted only when it is a bare `*` — so `*/2` restricts (robfig/cron's rule; Vixie cron treats any field starting with `*` as unrestricted). No names (MON, JAN), no `@daily` macros, no seconds: 0118's CHECK already holds an officer schedule's column to five fields, and 0166's a host job's.
func (Cron) Next ¶
Next is the first minute strictly after t (in UTC) that c matches, and false when there is none within cronHorizon.
func (Cron) ShortestInterval ¶
ShortestInterval is the shortest gap between two consecutive fires of c in the eight days after from (0 when it fires at most once there): what a host officer's spawn budget is sized from (officers.SpawnBudgetFor).