Skip to content

Commit

Permalink
add additional documentation for wait for schedule (#551)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnRoesler committed Aug 28, 2023
1 parent e3b4f5f commit c233d8d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(){ ... })

Expand Down
5 changes: 4 additions & 1 deletion scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit c233d8d

Please sign in to comment.