Help us shape the future of Go! Take the 2026 Go Developer Survey

schedule

package
v0.4.40 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package schedule implements cap/schedule.Engine (cron parsing and job fire-time evaluation) and schedule fire-metadata helpers used by runner/loop.

Index

Constants

This section is empty.

Variables

View Source
var (
	FireMeta               = capschedule.FireMeta
	SessionModeFromMeta    = capschedule.SessionModeFromMeta
	IsStatelessSessionMode = capschedule.IsStatelessSessionMode
	IsFireTurn             = capschedule.IsFireTurn
	IsFireStateless        = capschedule.IsFireStateless
)

Deprecated: schedule fire-metadata helpers moved to cap/schedule so runtime/loop and runtime/runner do not pull in the engine implementation. This alias keeps the old import path working; new code should import cap/schedule directly.

Functions

func New added in v0.3.33

func New(_ struct{}, _ struct{}) (capschedule.Engine, error)

New is the schedule/engine kind constructor.

func NextFire

func NextFire(job capschedule.Job, after time.Time) (time.Time, bool)

NextFire reports when a job should next run, given its anchor.

Types

type Engine added in v0.3.33

type Engine struct{}

Engine is the standard capschedule.Engine: cron parsing and job fire-time evaluation. Stateless; safe to share across instances.

func (Engine) NextFire added in v0.3.33

func (Engine) NextFire(job capschedule.Job, after time.Time) (time.Time, bool)

func (Engine) ParseCron added in v0.3.33

func (Engine) ParseCron(expr string) (capschedule.Cron, error)

type Schedule

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

Schedule is a parsed cron expression. Times are interpreted in the location of whatever time.Time it is asked about, so a schedule built from local time behaves like an OS crontab entry.

func ParseCron

func ParseCron(expr string) (Schedule, error)

ParseCron parses a 5-field cron expression: minute hour day-of-month month day-of-week. Each field accepts `*`, a number, `a-b`, comma-separated lists, and `*/n` or `a-b/n` steps. The @hourly/@daily/@weekly/@monthly/@yearly shorthands are also accepted.

func (Schedule) Matches

func (s Schedule) Matches(t time.Time) bool

Matches reports whether t (to the minute) satisfies the schedule.

func (Schedule) Next

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

Next returns the first matching minute strictly after t. The second result is false when nothing matches within the search horizon, which only happens for impossible dates such as "0 0 30 2 *".

func (Schedule) String

func (s Schedule) String() string

Jump to

Keyboard shortcuts

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