Documentation
¶
Index ¶
Constants ¶
const ( DefaultShutdownTimeout = 60 * time.Second DefaultJobTimeout = time.Hour )
Variables ¶
This section is empty.
Functions ¶
func ShouldRunLocalHour ¶ added in v1.6.0
func ShouldRunLocalNow ¶
ShouldRunLocalNow returns true if the local time in tzName matches hour:minute exactly.
Types ¶
type Option ¶ added in v1.6.0
type Option func(*Scheduler)
Option configures the Scheduler.
func WithJobTimeout ¶ added in v1.6.0
WithJobTimeout sets the default per-job timeout if ctx has no deadline.
func WithLogger ¶ added in v1.6.0
WithLogger sets the logger. Nil => Noop logger.
func WithShutdownTimeout ¶ added in v1.6.0
WithShutdownTimeout sets how long Start() waits for jobs to drain after ctx cancel.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler runs Jobs on a fixed tick schedule. It also supports one-shot jobs and prevents concurrent runs of the same logical task (by ID). For each distinct id, only one instance may run at the same time.
func (*Scheduler) Add ¶
Add registers a recurring job at the given slot (must be a multiple of granularity). id must be unique for each logical task; concurrent duplicates will be skipped.
func (*Scheduler) AddMany ¶
AddMany registers the same job on multiple slots. IDs must be distinct per logical task.