From c233d8d040a89a742cee1a25c88e8d3af640d29d Mon Sep 17 00:00:00 2001 From: John Roesler Date: Mon, 28 Aug 2023 11:36:25 -0500 Subject: [PATCH] add additional documentation for wait for schedule (#551) --- README.md | 8 ++++++++ scheduler.go | 5 ++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 59f49190..f4a227d6 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,14 @@ if err != nil { // handle the error related to setting up the job } +// to wait for the interval to pass before running the first job +// use WaitForSchedule or WaitForScheduleAll +s.Every(5).Second().WaitForSchedule().Do(func(){ ... }) + +s.WaitForScheduleAll() +s.Every(5).Second().Do(func(){ ... }) // waits for schedule +s.Every(5).Second().Do(func(){ ... }) // waits for schedule + // strings parse to duration s.Every("5m").Do(func(){ ... }) diff --git a/scheduler.go b/scheduler.go index ce86b486..2e7aa48b 100644 --- a/scheduler.go +++ b/scheduler.go @@ -550,7 +550,10 @@ func (s *Scheduler) EveryRandom(lower, upper int) *Scheduler { // parses with time.ParseDuration(). // Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". // -// The job is run immediately, unless StartAt or At is set. +// The job is run immediately, unless: +// * StartAt or At is set on the job, +// * WaitForSchedule is set on the job, +// * or WaitForScheduleAll is set on the scheduler. func (s *Scheduler) Every(interval interface{}) *Scheduler { job := s.getCurrentJob()