schedule

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2016 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstantSchedule

type ConstantSchedule struct {
	Interval time.Duration
}

func Every

func Every(duration time.Duration) ConstantSchedule

Every returns a ConstantSchedule that runs every duration given as parameter.

func (ConstantSchedule) Next

func (c ConstantSchedule) Next(current time.Time) time.Time

type CronSchedule

type CronSchedule struct {
	Expression *cronexpr.Expression
}

func Cron

func Cron(expression string) CronSchedule

Cron returns a CronSchedule using the cron expression giving as parameter of the function.

func (CronSchedule) Next

func (c CronSchedule) Next(current time.Time) time.Time

type RandomInterval

type RandomInterval struct {
	Interval   time.Duration
	Randomness float64
}

RandomInterval defines a random interval schedule.

func EveryRandom

func EveryRandom(interval time.Duration, plusOrMinus float64) RandomInterval

EveryRandom takes an interval with an ajustable plus or minus percentage of this interval. The plusOrMinus paramter should be between 0 and 1. It returns a Schedule. For example, EveryRandom(4*time.Second, 0.5) will return a Schedule that can return between 2 and 6 seconds.

func (RandomInterval) Next

func (r RandomInterval) Next(now time.Time) time.Time

func (RandomInterval) RandomRange

func (r RandomInterval) RandomRange() (min, max float64)

Jump to

Keyboard shortcuts

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