Documentation
¶
Overview ¶
Package automation holds the scheduling rules of agent automations: when a trigger fires, and what an automation's run is told. It does no I/O.
Index ¶
Constants ¶
const DefaultMinInterval = 5 * time.Minute
DefaultMinInterval is the shortest gap allowed between two runs.
Variables ¶
var ErrInvalidTrigger = errors.New("invalid trigger")
ErrInvalidTrigger wraps every trigger validation failure.
Functions ¶
func RenderInstruction ¶
RenderInstruction substitutes {{now}}, {{last_run_at}}, {{last_success_at}}, {{run_id}} and {{automation_name}}. Unknown placeholders are left alone so a literal "{{" in a prompt survives.
Types ¶
type RunVars ¶
type RunVars struct {
Now time.Time
LastRunAt *time.Time
LastSuccessAt *time.Time
RunID string
AutomationName string
Location *time.Location
}
RunVars are the values an instruction may reference.
type Schedule ¶
type Schedule struct {
// contains filtered or unexported fields
}
Schedule is a validated trigger.
func Parse ¶
func Parse(t types.AutomationTrigger) (*Schedule, error)
Parse validates t. A cron expression has five fields (minute first) or six (seconds first), or is a descriptor such as @daily; it is evaluated in t.Timezone, which a CRON_TZ= prefix in the expression may not override.
func (*Schedule) CheckInterval ¶
CheckInterval rejects a cron trigger that can fire twice within min. It looks at the gaps over the next days, which catches expressions such as "* * * * *" and "*/2 9 * * *" alike.
func (*Schedule) Next ¶
Next is the first time the trigger fires strictly after after, or nil when it never fires again.
func (*Schedule) Trigger ¶
func (s *Schedule) Trigger() types.AutomationTrigger
Trigger is the normalized trigger.