Version: v0.0.0-...-e013def Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2022 License: Apache-2.0 Imports: 7 Imported by: 5




This section is empty.


View Source
var DistantFuture = time.Unix(4604952467, 0).UTC()

DistantFuture is Jan 2116. It is used to indicate that next tick should not happen.


This section is empty.


type Schedule

type Schedule struct {
	// contains filtered or unexported fields

Schedule knows when to run a periodic job (given current time and possibly a current state of the job).

See 'Parse' for a list of supported kinds of schedules.

func Parse

func Parse(expr string, randSeed uint64) (sched *Schedule, err error)

Parse converts human readable definition of a schedule to *Schedule object.

Supported kinds of schedules (illustrated by examples):

  • "* 0 * * * *": standard cron-like expression. Cron engine will attempt to start a job at specified moments in time (based on UTC clock). If when triggering a job, previous invocation is still running, an overrun will be recorded (and next attempt to start a job happens based on the schedule, not when the previous invocation finishes). This is absolute schedule (i.e. doesn't depend on job state).
  • "with 10s interval": runs invocations in a loop, waiting 10s after finishing invocation before starting a new one. This is relative schedule. Overruns are not possible.
  • "continuously" is alias for "with 0s interval", meaning the job will run in a loop without any pauses.
  • "triggered" schedule indicates that job is always started via a trigger. 'Next' always returns DistantFuture constant.

func (*Schedule) IsAbsolute

func (s *Schedule) IsAbsolute() bool

IsAbsolute is true for schedules that do not depend on a job state.

Absolute schedules are basically static time tables specifying when to attempt to run a job.

Non-absolute (aka relative) schedules may use job state transition times to make decisions.

See comment for 'Parse' for some examples.

func (*Schedule) Next

func (s *Schedule) Next(now, prev time.Time) time.Time

Next tells when to run the job the next time.

'now' is current time. 'prev' is when previous invocation has finished (or zero time for first invocation).

func (*Schedule) String

func (s *Schedule) String() string

String serializes the schedule to a human readable string.

It can be passed to Parse to get back the schedule.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL