Documentation
¶
Overview ¶
Package schedule is the pure core of scheduled sends (docs/specs/schedule.md): argument parsing for --at/--every/--cron, next-fire computation, and the missfire decision the server's firing loop applies to a claimed row. Deterministic — callers inject `now`; nothing here reads the wall clock.
Index ¶
Constants ¶
const MinEvery = time.Second
MinEvery is the smallest accepted --every interval. It matches the firing loop's tick resolution.
const MissfireGrace = 60 * time.Second
MissfireGrace bounds how late a recurring fire may run. A recurring occurrence more than MissfireGrace overdue (server downtime, stalled loop) is dropped — next_fire_at advances past now with no catch-up burst. One-offs are exempt: they fire once however late.
Variables ¶
var ErrPast = errors.New("instant is not in the future")
ErrPast marks an --at instant that isn't strictly in the future. Callers branch on it (errors.Is) to word the user-facing message separately from parse failures.
Functions ¶
func NextAfter ¶
NextAfter computes the first fire instant strictly after `after`, or ok=false when the schedule has no future fire (a spent one-off).
func ParseAt ¶
ParseAt resolves an --at argument to a concrete instant. Accepted forms: RFC3339 (offset preserved — `schedule ls` renders the SCHEDULE cell as typed), "YYYY-MM-DD HH:MM" in loc, and relative "+<goduration>". The result must be strictly after now.
Types ¶
type Decision ¶
type Decision struct {
Fire bool // publish now
Done bool // schedule is spent — delete the row
Next time.Time // next_fire_at to store (meaningless when Done)
}
Decision is the firing loop's verdict on one claimed row.
func Decide ¶
Decide applies the missfire policy to a schedule whose stored next-fire is `next`, at wall-clock `now`:
- not yet due → no fire, next unchanged
- one-off due → fire (however late), done
- recurring ≤ grace late → fire, advance to the next occurrence
- recurring > grace late → drop the missed occurrences, advance