Documentation
¶
Overview ¶
Package task provides scheduled task definitions, schedule parsing, and a scheduler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EnvFromContext ¶
EnvFromContext returns task-scoped environment variables, or nil if none set.
func ParseSchedule ¶
func ParseSchedule(raw string) (gocron.JobDefinition, error)
ParseSchedule parses a schedule string with a prefix into a gocron JobDefinition.
Supported prefixes:
- "cron: <expr>" → CronJob (standard 5-field crontab)
- "every: <duration>" → DurationJob (e.g. "every: 30m", "every: 2h")
- "daily: <HH:MM,...>" → DailyJob (e.g. "daily: 09:00,17:00")
- "weekly: <days> <HH:MM>" → WeeklyJob (e.g. "weekly: mon,wed,fri 09:00")
- "monthly: <days> <HH:MM>" → MonthlyJob (e.g. "monthly: 1,15 09:00")
- "once: <RFC3339>" → OneTimeJob (e.g. "once: 2026-03-01T09:00:00Z")
- "once: startup" → OneTimeJob that fires immediately when the scheduler starts
Types ¶
type ForEach ¶
type ForEach struct {
File string `yaml:"file"` // Read lines from this file
Shell string `yaml:"shell"` // Run command, read lines from stdout
ContinueOnError bool `yaml:"continue_on_error"` // Log per-item errors and continue instead of aborting
Retries int `yaml:"retries"` // Additional attempts per failed item (0 = no retry)
}
ForEach defines the iteration source for task commands.
type RunFunc ¶
RunFunc is the callback invoked for each task execution. It receives the task and must handle the full execution lifecycle.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler wraps gocron.Scheduler and manages task job registration.
func NewScheduler ¶
NewScheduler creates a Scheduler with concurrency controls, registers all scheduled tasks, but does not start. concurrency caps the maximum number of tasks running in parallel across all jobs.
type Task ¶
type Task struct {
Name string
Inherit []string // parent names (for display)
Description string
Schedule string
Timeout time.Duration
Disabled *bool
Agent string
Mode string
Session string
Workdir string
Tools tool.Filter
Features yaml.Node // raw YAML for feature overrides, decoded by consumer into config.Features
Pre []string
Commands []string
Post []string
ForEach *ForEach
Finally []string
OnMaxSteps []string
Env map[string]string
EnvFile []string
Source string // file path this task was loaded from
}
Task is a named scheduled task definition.
func (*Task) ApplyDefaults ¶
func (t *Task) ApplyDefaults()
func (Task) IsDisabled ¶
IsDisabled returns true if the task is explicitly disabled.
func (Task) IsManualOnly ¶
IsManualOnly returns true when no schedule is configured (run via CLI only).
func (Task) ScheduleDisplay ¶
ScheduleDisplay returns the schedule string, or "manual" if unset.
func (Task) StatusDisplay ¶
StatusDisplay returns "enabled" or "disabled".
type Tasks ¶
Tasks maps task names to their definitions.
func (Tasks) Display ¶
Display renders a table of all tasks with dynamic column widths and a header separator.
func (*Tasks) Load ¶
Load reads YAML files and merges all task definitions into the map. Each file contains a map of task names to their definitions. Supports config inheritance via the `inherit` field within task definitions.
Task files use two delimiter systems:
- {{ }} for load-time templates (structural generation, env vars, --set vars, sprig)
- $[[ ]] for runtime templates (per-command vars like .Item, .Workdir)
Load-time templates are expanded before YAML parsing (Phase A). After parsing, convertRuntimeDelimiters replaces $[[ ... ]] → {{ ... }} on command-like fields so the runtime template engine sees standard {{ }} with full sprig support.
Command-like fields (pre, commands, post, foreach, finally, on_max_steps) are preserved from the initial parse so runtime template expressions survive Phase C's metadata expansion.