Versions in this module Expand all Collapse all v0 v0.2.1 May 8, 2026 v0.2.0 May 8, 2026 v0.1.0 Apr 28, 2026 Changes in this version + var ErrAlreadyRunning = errors.New("cron: job already running") + var ErrCapacityReached = errors.New("cron: capacity reached") + var ErrConcurrencyLimit = errors.New("cron: max concurrent reached") + var ErrCronStopping = errors.New("cron: scheduler stopping") + var ErrEntryNotFound = errors.New("cron: entry not found") + var ErrJobTimeout = errors.New("cron: job timeout") + var ErrSchedulerNotRunning = errors.New("cron: scheduler not running") + var ErrSchedulerStopped = errors.New("cron: scheduler stopped") + func Between(s Schedule, start, end time.Time) []time.Time + func BetweenWithLimit(s Schedule, start, end time.Time, limit int) []time.Time + func Count(s Schedule, start, end time.Time) int + func CountWithLimit(s Schedule, start, end time.Time, limit int) int + func IsTriggered(s Schedule) bool + func Matches(s Schedule, t time.Time) bool + func NextN(s Schedule, from time.Time, n int) []time.Time + func UpcomingSeq(s Schedule, from time.Time) iter.Seq[time.Time] + func ValidateSpec(spec string) error + func ValidateSpecWith(spec string, p Parser) error + type ConstantDelay time.Duration + func (d ConstantDelay) Next(now time.Time) time.Time + func (d ConstantDelay) String() string + type Cron struct + func New(opts ...Option) *Cron + func (c *Cron) Add(spec string, j Job, opts ...EntryOption) (EntryID, error) + func (c *Cron) AddSchedule(s Schedule, j Job, opts ...EntryOption) (EntryID, error) + func (c *Cron) Entries() iter.Seq[Entry] + func (c *Cron) Entry(id EntryID) (Entry, bool) + func (c *Cron) Remove(id EntryID) bool + func (c *Cron) Running() bool + func (c *Cron) Start() error + func (c *Cron) Stop(ctx context.Context) error + func (c *Cron) Trigger(id EntryID) error + func (c *Cron) TriggerByName(name string) (int, error) + type Entry struct + ID EntryID + Name string + Next time.Time + Prev time.Time + Schedule Schedule + Spec string + func (e Entry) LogValue() slog.Value + func (e Entry) Valid() bool + type EntryID uint64 + func (id EntryID) LogValue() slog.Value + func (id EntryID) String() string + type EntryOption func(*entryConfig) + func WithEntryChain(wrappers ...Wrapper) EntryOption + func WithEntryRetry(p RetryPolicy) EntryOption + func WithName(name string) EntryOption + func WithTimeout(d time.Duration) EntryOption + type EventJobComplete struct + Duration time.Duration + EntryID EntryID + Err error + FireAt time.Time + Name string + ScheduledAt time.Time + type EventJobStart struct + EntryID EntryID + FireAt time.Time + Name string + ScheduledAt time.Time + type EventMissed struct + EntryID EntryID + Lateness time.Duration + Name string + Policy MissedFirePolicy + ScheduledAt time.Time + type EventSchedule struct + EntryID EntryID + Name string + Next time.Time + Schedule Schedule + type HookDroppedRecorder interface + HookDropped func() + type Job interface + Run func(ctx context.Context) error + type JobCompleteHook interface + OnJobComplete func(EventJobComplete) + type JobCompletedRecorder interface + JobCompleted func(name string, dur time.Duration, err error) + type JobFunc func(ctx context.Context) error + func (f JobFunc) Run(ctx context.Context) error + type JobMissedRecorder interface + JobMissed func(name string, lateness time.Duration) + type JobScheduledRecorder interface + JobScheduled func(name string) + type JobStartHook interface + OnJobStart func(EventJobStart) + type JobStartedRecorder interface + JobStarted func(name string) + type MissedFirePolicy uint8 + const MissedRunOnce + const MissedSkip + func (p MissedFirePolicy) String() string + type MissedHook interface + OnMissedFire func(EventMissed) + type NoopRecorder struct + func (NoopRecorder) HookDropped() + func (NoopRecorder) JobCompleted(string, time.Duration, error) + func (NoopRecorder) JobMissed(string, time.Duration) + func (NoopRecorder) JobScheduled(string) + func (NoopRecorder) JobStarted(string) + func (NoopRecorder) QueueDepth(int) + type Option func(*config) + func WithChain(wrappers ...Wrapper) Option + func WithHookBuffer(n int) Option + func WithHooks(hooks ...any) Option + func WithJitter(max time.Duration) Option + func WithLocation(loc *time.Location) Option + func WithLogger(l *slog.Logger) Option + func WithMaxConcurrent(n int) Option + func WithMaxEntries(n int) Option + func WithMissedFire(p MissedFirePolicy) Option + func WithMissedTolerance(d time.Duration) Option + func WithParser(p Parser) Option + func WithRecorder(r any) Option + func WithRetry(p RetryPolicy) Option + func WithStandardParser(opts ...ParserOption) Option + type ParseError struct + Err error + Field string + Pos int + Reason string + Spec string + func (e *ParseError) Error() string + func (e *ParseError) Unwrap() error + type Parser interface + Parse func(spec string) (Schedule, error) + type ParserOption func(*parserConfig) + func WithDefaultLocation(loc *time.Location) ParserOption + func WithParserExt(ext Parser) ParserOption + func WithSeconds() ParserOption + type QueueDepthRecorder interface + QueueDepth func(n int) + type RetryOption func(*RetryPolicy) + func RetryInitial(d time.Duration) RetryOption + func RetryJitterFrac(f float64) RetryOption + func RetryMaxDelay(d time.Duration) RetryOption + func RetryMultiplier(m float64) RetryOption + type RetryPolicy struct + Initial time.Duration + JitterFrac float64 + MaxDelay time.Duration + MaxRetries int + Multiplier float64 + func Retry(maxRetries int, opts ...RetryOption) RetryPolicy + func (p RetryPolicy) IsZero() bool + func (p RetryPolicy) Wrapper() Wrapper + type Schedule interface + Next func(now time.Time) time.Time + func TriggeredSchedule() Schedule + type ScheduleHook interface + OnSchedule func(EventSchedule) + type SpecAnalysis struct + Descriptor string + Err error + Interval time.Duration + IsTriggered bool + Location *time.Location + NextRun time.Time + Spec string + Valid bool + func AnalyzeSpec(spec string, now time.Time) SpecAnalysis + func AnalyzeSpecWith(spec string, p Parser, now time.Time) SpecAnalysis + type SpecSchedule struct + func (s *SpecSchedule) Location() *time.Location + func (s *SpecSchedule) LogValue() slog.Value + func (s *SpecSchedule) Next(t time.Time) time.Time + func (s *SpecSchedule) Upcoming(from time.Time) iter.Seq[time.Time] + type StandardParser struct + func NewStandardParser(opts ...ParserOption) *StandardParser + func (p *StandardParser) Parse(spec string) (Schedule, error) + type Upcoming interface + Upcoming func(from time.Time) iter.Seq[time.Time] + type Wrapper func(Job) Job + func Chain(wrappers ...Wrapper) Wrapper