luci: Index | Files

package schedule

import ""


Package Files



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

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

type Schedule Uses

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 Uses

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 "Run now"
  button. 'Next' always returns DistantFuture constant.

func (*Schedule) IsAbsolute Uses

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 Uses

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 Uses

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.

Package schedule imports 7 packages (graph) and is imported by 10 packages. Updated 2018-08-14. Refresh now. Tools for package owners.