Documentation
¶
Overview ¶
Package cron holds the pure scheduling domain for rysh's in-daemon cron service: the Job model, schedule parsing/validation (via robfig/cron), and next-run computation. It has no actor or NATS dependencies so it is fully unit-testable; the actor-side store, ticker, and job firing live in internal/actors/workspace_cron.go.
Index ¶
Constants ¶
const AutoDisableAfter = 5
AutoDisableAfter is the consecutive-failure count at which a job is auto-disabled.
const MaxJobs = 100
MaxJobs caps the number of jobs a session may hold.
const MaxRunHistory = 20
MaxRunHistory caps the per-job ring buffer of recent run records.
Variables ¶
This section is empty.
Functions ¶
func ParseSchedule ¶
ParseSchedule parses a cron spec (5-field standard, or @every/@daily/… descriptors) with an optional timezone.
Types ¶
type Job ¶
type Job struct {
ID string `json:"id"`
Name string `json:"name"` // unique handle for ##cron commands
Schedule string `json:"schedule"` // "0 9 * * *", "@every 15m", "@daily"
Timezone string `json:"timezone,omitempty"`
Target string `json:"target"` // pane id/name, or "active"
Mode string `json:"mode"` // shell | prompt | rysh (inferred if empty)
Input string `json:"input"` // text to inject (##…, @agent…, prompt, shell)
Enabled bool `json:"enabled"`
NextRun time.Time `json:"next_run"`
LastRun time.Time `json:"last_run,omitempty"`
LastStatus string `json:"last_status,omitempty"`
RunCount int `json:"run_count"`
Runs []Run `json:"runs,omitempty"`
// FailStreak counts consecutive failures; the actor auto-disables a job
// after AutoDisableAfter consecutive failures so a broken job can't fire
// forever.
FailStreak int `json:"fail_streak,omitempty"`
}
Job is a scheduled rysh input injection.
func (*Job) ComputeNext ¶
ComputeNext sets NextRun to the first fire time strictly after `from`. Returns an error if the schedule no longer parses (e.g. corrupted KV).
func (*Job) Due ¶
Due reports whether the job should fire at time `now`: enabled and its NextRun has arrived.
func (*Job) InferMode ¶
InferMode returns the effective input mode: the explicit Mode, else inferred from the input prefix (## / @ → those are handled by the dispatcher regardless of mode, so default to "prompt" for bare text is wrong for shell; we default bare text to "shell" to match a terminal's expectation).