Documentation
¶
Index ¶
- func NextTime(expr string, from time.Time) (time.Time, error)
- type Job
- type Scheduler
- func (s *Scheduler) Create(cronExpr, prompt string, recurring bool) (Job, error)
- func (s *Scheduler) Delete(id string) bool
- func (s *Scheduler) DeleteWithError(id string) (bool, error)
- func (s *Scheduler) Get(id string) (Job, bool)
- func (s *Scheduler) List() []Job
- func (s *Scheduler) Load(workspaceDir string)
- func (s *Scheduler) SetEnqueue(fn func(prompt string))
- func (s *Scheduler) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NextTime ¶
NextTime calculates the next time that matches the 5-field cron expression after the given 'from' time. Returns the next fire time or an error.
Supported syntax per field:
- * — any value
- */N — every Nth value
- N — exact value
- N,M,K — list of values
- N-M — range (inclusive)
- N-M/S — range with step
Types ¶
type Job ¶
type Job struct {
ID string
CronExpr string
Prompt string
Recurring bool
CreatedAt time.Time
NextFire time.Time
}
Job represents a scheduled prompt job.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages cron-like prompt scheduling with optional persistence.
func NewScheduler ¶
NewScheduler creates a scheduler with the given enqueue callback and optional persistence path. If storePath is empty, no persistence is used (useful for tests).
func (*Scheduler) Create ¶
Create adds a new scheduled job and returns its snapshot. The cron expression is a standard 5-field format:
minute hour day-of-month month day-of-week
Supports: *, */N, N, N-M, N,M,K, N-M/S
func (*Scheduler) DeleteWithError ¶ added in v1.3.68
DeleteWithError removes a scheduled job by ID and reports persistence errors.
func (*Scheduler) Load ¶ added in v1.3.68
Load reads persisted recurring jobs for the given workspace and schedules them. Must be called after NewScheduler, before any Create/Delete calls. If storePath is empty or the file doesn't exist, Load is a no-op.
func (*Scheduler) SetEnqueue ¶
SetEnqueue sets or replaces the enqueue callback. Use this when the scheduler is created before the TUI is available.