cronx

package
v0.69.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package cronx is graith's single, owned abstraction for cron schedules. It exists so config validation and daemon execution parse cron with exactly one grammar — before this package the two lived in separate robfig parsers (config.cronSpecParser and daemon.cronParser) that could silently drift.

The grammar is deliberately narrow and matches what the docs promise: a five-field expression, or one of four descriptors. See Grammar for the full contract. Anything outside it — six/seven-field forms (seconds/year), the undocumented robfig descriptors (@yearly/@annually/@midnight/@reboot/@every), and Quartz/gronx extensions (?, L, W, #) — is rejected, so what config validation accepts is exactly what the runtime can fire.

The engine underneath is robfig/cron/v3, used only as a parser + Next() (never its scheduler). We evaluated replacing it with github.com/adhocore/gronx (issue #1213) and rejected the swap: gronx v1.20.0 (the latest) computes wrong next-fire times — ones its own IsDue rejects — for day-of-month values absent in the current month (29/30/31), leap-day Feb 29, and DST fall-back transitions. The differential corpus in cronx_diff_test.go pins that evidence and acts as a tripwire if a future gronx fixes it. See docs/design/2026-07-16-cron-parser-evaluation.md.

Index

Constants

View Source
const Grammar = `` /* 1054-byte string literal not displayed */

Grammar documents the exact cron grammar graith accepts. It is the single source of truth referenced by the config docs and the trigger docs.

Variables

This section is empty.

Functions

func Validate

func Validate(spec string) error

Validate reports whether spec is a well-formed graith cron expression, returning the same descriptive error Parse would. Config validation uses it so it rejects exactly what the runtime cannot fire.

Types

type Schedule

type Schedule struct {
	// contains filtered or unexported fields
}

Schedule is a parsed graith cron schedule. The zero value is not usable; obtain one from Parse.

func Parse

func Parse(spec string) (Schedule, error)

Parse validates spec against Grammar and returns a Schedule. A returned error is safe to surface to users: it explains what was rejected.

func (Schedule) Next

func (s Schedule) Next(t time.Time) time.Time

Next returns the next activation time strictly after t, in t's location. It returns the zero time if the schedule has no next activation (e.g. an impossible date like Feb 30) — callers must treat a zero return as "never fires" rather than "fire now".

func (Schedule) String

func (s Schedule) String() string

String returns the original spec, for logging and diagnostics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL