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 ¶
- Variables
- func Validate(expr string, loc *time.Location) (time.Time, error)
- type Deliverer
- type Executor
- type Options
- type Runner
- func (r *Runner) Location() *time.Location
- func (r *Runner) Recompute(ctx context.Context, job *store.CronJob) error
- func (r *Runner) Reconfigure(enabled bool, timezone string, maxConcurrent int, historyLimit int) error
- func (r *Runner) RunNow(ctx context.Context, id string) error
- func (r *Runner) Start(ctx context.Context)
- type Schedule
Constants ¶
This section is empty.
Variables ¶
var ErrAlreadyRunning = errors.New("cron: job already running")
ErrAlreadyRunning is returned when the same job is already executing.
var ErrCapacityBusy = errors.New("cron: scheduler at capacity")
ErrCapacityBusy is returned when the concurrency limit is full.
var ErrDisabled = errors.New("cron: scheduler disabled")
ErrDisabled is returned to scheduled callers when the runner is disabled. RunNow does not observe this error; manual runs are allowed regardless.
Functions ¶
Types ¶
type Options ¶
type Options struct {
Store store.Store
Execute Executor
Deliver Deliverer
Timezone string
MaxConcurrent int
HistoryLimit int
// Enabled controls scheduled activations. nil defaults to true; Main
// should call Reconfigure at boot to apply the configured value.
Enabled *bool
}
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. Runtime configuration is swappable via Reconfigure without stopping the loop or cancelling jobs that are already executing.
func (*Runner) Reconfigure ¶ added in v0.4.0
func (r *Runner) Reconfigure(enabled bool, timezone string, maxConcurrent int, historyLimit int) error
Reconfigure applies new runtime configuration atomically. Inputs are validated first; a rejected call leaves the runner untouched. A recompute is signalled only when the timezone or enabled flag actually changes.
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule is a parsed five-field cron expression.
func Parse ¶
Parse compiles a cron expression. It accepts the five-field form plus the common @daily style shorthands and "@every <duration>".