Documentation
¶
Overview ¶
Package scheduler implements a cron-based scheduler that fires registered schedules (see internal/schedule) and creates Tasks at their scheduled times.
The scheduler runs as a singleton goroutine started from cmd/taskguild-server/run.go. It uses github.com/robfig/cron/v3 as the underlying cron runner with the standard 5-field parser and the server's local timezone. Missed firings during downtime are skipped (no catch-up).
Index ¶
- type Scheduler
- func (s *Scheduler) Add(sched *schedule.Schedule) error
- func (s *Scheduler) NextRun(expr string, from time.Time) time.Time
- func (s *Scheduler) Remove(id string)
- func (s *Scheduler) SetLocation(loc *time.Location)
- func (s *Scheduler) Start(ctx context.Context)
- func (s *Scheduler) Update(sched *schedule.Schedule) error
- type TaskCreator
- type TaskCreatorAdapter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages the cron entries for all enabled schedules and dispatches task creation when entries fire.
func New ¶
func New(repo schedule.Repository, tc TaskCreator) *Scheduler
New creates a Scheduler. Start must be called to begin firing entries.
func (*Scheduler) Add ¶
Add registers a schedule. If the schedule is already registered, the previous entry is removed first.
func (*Scheduler) NextRun ¶
NextRun computes the next firing time of expr (5-field cron) after from. Returns the zero Time if the expression is invalid.
func (*Scheduler) SetLocation ¶
SetLocation overrides the cron timezone (default: time.Local). Must be called before Start.
type TaskCreator ¶
type TaskCreator interface {
CreateTaskFromSchedule(ctx context.Context, s *schedule.Schedule, firedAt time.Time) (*task.Task, error)
}
TaskCreator abstracts the cross-package call into internal/task so the scheduler can be tested without spinning up a full task.Server.
type TaskCreatorAdapter ¶
TaskCreatorAdapter bridges scheduler.TaskCreator to task.Server. It expands title/description placeholders and attaches schedule provenance metadata.
func NewTaskCreatorAdapter ¶
func NewTaskCreatorAdapter(ts *task.Server) *TaskCreatorAdapter
NewTaskCreatorAdapter constructs an adapter wired to the provided task server.