Documentation
¶
Overview ¶
Package scheduler handles time-based job scheduling. Supports cron expressions, intervals, and time window constraints.
Index ¶
- Variables
- type Job
- type Scheduler
- func (s *Scheduler) AddJob(job Job)
- func (s *Scheduler) IsInWindow(t time.Time) bool
- func (s *Scheduler) IsRunning() bool
- func (s *Scheduler) NextRun() time.Time
- func (s *Scheduler) NextRuns(n int) ([]time.Time, error)
- func (s *Scheduler) Schedule(at time.Time, job func())
- func (s *Scheduler) ScheduleCron(expr string, job func()) error
- func (s *Scheduler) ScheduleInterval(d time.Duration, job func()) error
- func (s *Scheduler) SetCron(expr string) error
- func (s *Scheduler) SetInterval(d time.Duration) error
- func (s *Scheduler) SetWindow(cfg *config.WindowConfig) error
- func (s *Scheduler) Start(ctx context.Context) error
- func (s *Scheduler) Stop() error
- type TimeOfDay
- type Window
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidCron = errors.New("invalid cron expression") ErrInvalidInterval = errors.New("invalid interval duration") ErrInvalidWindow = errors.New("invalid time window") ErrInvalidTimezone = errors.New("invalid timezone") ErrNoSchedule = errors.New("no schedule configured (need cron or interval)") ErrAlreadyRunning = errors.New("scheduler already running") ErrNotRunning = errors.New("scheduler not running") )
Errors for scheduler operations.
Functions ¶
This section is empty.
Types ¶
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages scheduled nightshift runs.
func NewFromConfig ¶
func NewFromConfig(cfg *config.ScheduleConfig) (*Scheduler, error)
NewFromConfig creates a scheduler from configuration.
func (*Scheduler) IsInWindow ¶
IsInWindow checks if the given time is within the allowed execution window. Returns true if no window is configured.
func (*Scheduler) NextRuns ¶
NextRuns returns the next N scheduled run times without starting the scheduler.
func (*Scheduler) ScheduleCron ¶
ScheduleCron adds a recurring job using cron expression. Deprecated: Use SetCron and AddJob instead.
func (*Scheduler) ScheduleInterval ¶
ScheduleInterval adds a recurring job using interval.
func (*Scheduler) SetInterval ¶
SetInterval sets the interval for scheduling.
func (*Scheduler) SetWindow ¶
func (s *Scheduler) SetWindow(cfg *config.WindowConfig) error
SetWindow sets the time window constraint.
type TimeOfDay ¶
TimeOfDay represents a time within a day (hour and minute).
func ParseTimeOfDay ¶
ParseTimeOfDay parses a time string like "22:00" or "06:30".