oncalendar

package
v0.16.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package oncalendar parses the subset of systemd's OnCalendar syntax that Miren accepts for scheduled tasks, and evaluates the firing times it describes.

OnCalendar is used in preference to cron because it reads left to right: "Mon *-*-* 09:00:00" is legible as "Monday at 9am" without knowing which position means what, where cron's "0 9 * * 1" is not.

Everything is evaluated in UTC. A calendar expression is a pure function of its own text, so every replica derives the same firing times from the stored config without coordinating.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DesugarEvery

func DesugarEvery(d time.Duration) (string, error)

DesugarEvery converts an `every = "6h"` interval into the equivalent calendar expression. `every` is pure sugar: only the calendar form is ever stored, so there is exactly one scheduling mechanism.

The expansion is anchored to midnight UTC rather than to the deploy. An interval measured from "whenever this was deployed" would move every time the app ships — a daily job on an app that deploys ten times a day would fire ten times a day — and tick-based dedup could not catch it, because a new anchor produces a new tick and therefore a new entity ID. A day-aligned schedule doesn't move when you deploy, and every replica derives the same firing times from the config alone.

The cost is that only durations tiling a day evenly are accepted.

Types

type Expr

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

Expr is a parsed calendar expression.

func Parse

func Parse(expr string) (*Expr, error)

Parse parses a calendar expression. Accepted forms:

daily                       (and the other keywords)
HH:MM[:SS]                  every day at that time
YYYY-MM-DD HH:MM[:SS]
MM-DD HH:MM[:SS]            any year
DOW YYYY-MM-DD HH:MM[:SS]
DOW HH:MM[:SS]

Every numeric field accepts `*`, a value, a comma list, an `a..b` range, and an `a/step` or `*/step` repetition. Day-of-week accepts names, comma lists, and `Mon..Fri` ranges.

func (*Expr) Next

func (e *Expr) Next(after time.Time) (time.Time, bool)

Next returns the first firing time strictly after t, and whether one exists.

func (*Expr) String

func (e *Expr) String() string

String returns the expression's canonical text, which is what gets stored and displayed.

Jump to

Keyboard shortcuts

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