cron

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2026 License: Apache-2.0 Imports: 10 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 cron implements the built-in scheduler: a five-field cron parser and a runner that executes natural-language jobs through the agent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(expr string, loc *time.Location) (time.Time, error)

Validate checks an expression and returns the next activation for previews.

Types

type Deliverer

type Deliverer func(ctx context.Context, target, text string) error

Deliverer optionally forwards a job's output to a messaging target.

type Executor

type Executor func(ctx context.Context, job store.CronJob) (sessionID, reply string, err error)

Executor runs one scheduled job's prompt and returns its final reply.

type Options

type Options struct {
	Store         store.Store
	Execute       Executor
	Deliver       Deliverer
	Timezone      string
	MaxConcurrent int
	HistoryLimit  int
}

Options configures a Runner.

type Runner

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

Runner ticks once a minute and executes jobs whose schedule has come due.

func New

func New(o Options) *Runner

New builds a Runner.

func (*Runner) Location

func (r *Runner) Location() *time.Location

Location reports the scheduler timezone.

func (*Runner) Recompute

func (r *Runner) Recompute(ctx context.Context, job *store.CronJob) error

Recompute refreshes one job's next activation, e.g. after an edit.

func (*Runner) RunNow

func (r *Runner) RunNow(ctx context.Context, id string) error

RunNow executes a job immediately, outside its schedule.

func (*Runner) Start

func (r *Runner) Start(ctx context.Context)

Start runs the scheduler loop until ctx is cancelled.

type Schedule

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

Schedule is a parsed five-field cron expression.

func Parse

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

Parse compiles a cron expression. It accepts the five-field form plus the common @daily style shorthands and "@every <duration>".

func (*Schedule) Next

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

Next returns the first activation strictly after t, or the zero time when the expression can never fire (searched up to five years ahead).

func (*Schedule) String

func (s *Schedule) String() string

String returns the original expression.

Jump to

Keyboard shortcuts

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