schedule

package
v0.58.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const MinEvery = time.Second

MinEvery is the smallest accepted --every interval. It matches the firing loop's tick resolution.

View Source
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

View Source
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

func NextAfter(s Spec, after time.Time) (time.Time, bool)

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

func ParseAt(arg string, now time.Time, loc *time.Location) (time.Time, error)

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.

func ParseCron

func ParseCron(expr string) error

ParseCron validates a standard 5-field cron expression (minute hour dom month dow).

func ParseEvery

func ParseEvery(arg string) (time.Duration, error)

ParseEvery validates an --every argument: a positive Go duration of at least MinEvery.

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

func Decide(s Spec, next, now time.Time) Decision

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

type Kind

type Kind string

Kind discriminates the three schedule shapes. The strings are wire values (cliproto.ScheduleCreateRequest.Kind, schedules.kind column).

const (
	KindAt    Kind = "at"
	KindEvery Kind = "every"
	KindCron  Kind = "cron"
)

type Spec

type Spec struct {
	Kind  Kind
	At    time.Time
	Every time.Duration
	Cron  string
	Loc   *time.Location
}

Spec is one schedule's shape. At doubles as the fire instant for KindAt and the anchor (creation instant) for KindEvery's interval grid. Loc is the IANA zone cron wall-clock times resolve in.

Jump to

Keyboard shortcuts

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