Documentation
¶
Overview ¶
Package scheduler wraps robfig/cron with a fluent API for defining scheduled tasks, named jobs, and graceful shutdown.
Index ¶
- type Job
- type Scheduler
- func (s *Scheduler) Daily(at, name string, fn func(ctx context.Context) error) (*Job, error)
- func (s *Scheduler) Every(expr, name string, fn func(ctx context.Context) error) *Job
- func (s *Scheduler) Hourly(name string, fn func(ctx context.Context) error) *Job
- func (s *Scheduler) Start() error
- func (s *Scheduler) Stop() context.Context
- func (s *Scheduler) WithStopTimeout(d time.Duration) *Scheduler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job is a named scheduled task.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages cron-based scheduled tasks.
func (*Scheduler) Daily ¶
Daily schedules fn to run at a specific time each day (HH:MM, 24h).
s.Daily("03:00", "nightly-backup", func(ctx context.Context) error { ... })
func (*Scheduler) Every ¶
Every schedules fn using a cron expression (supports seconds: "*/5 * * * * *"). It may be called before or after Start: jobs added after Start are registered with the running cron engine immediately.
s.Every("0 * * * * *", "hourly-cleanup", func(ctx context.Context) error { ... })
func (*Scheduler) Start ¶
Start registers all jobs and starts the cron engine. Calling Start more than once is a no-op.
Click to show internal directories.
Click to hide internal directories.