schedule

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2017 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dump

func Dump(schedule Schedule, after time.Time, until time.Time) chan DumpEntry

func DumpJson

func DumpJson(writer io.Writer, schedule Schedule, after time.Time, until time.Time) (int, error)

Types

type BasicSchedule

type BasicSchedule struct {
	// contains filtered or unexported fields
}

func NewBasicSchedule

func NewBasicSchedule() *BasicSchedule

func (*BasicSchedule) Next

func (s *BasicSchedule) Next(after time.Time) time.Time

func (*BasicSchedule) Set

func (s *BasicSchedule) Set(name string, nexter Nexter)

func (*BasicSchedule) Tick

type DumpEntry

type DumpEntry struct {
	After time.Time
	Tasks []string
}

type NextFunc

type NextFunc func(after time.Time) time.Time

func (NextFunc) Next

func (f NextFunc) Next(after time.Time) time.Time

type NextList

type NextList []Nexter

func (*NextList) Add

func (list *NextList) Add(nexter Nexter)

func (*NextList) Clear

func (list *NextList) Clear()

func (*NextList) Next

func (list *NextList) Next(after time.Time) time.Time

type NextTime

type NextTime time.Time

func (NextTime) Next

func (t NextTime) Next(after time.Time) time.Time

type Nexter

type Nexter interface {
	// starting from "after", returns the time of the "next" event in the schedule,
	// which must be greater than "after".
	// A zero-value is used to indicate that no "next" event is known when
	// starting from the given time. Due to this, results are undefined when
	// "after" is a zero-value.
	Next(after time.Time) time.Time
}

type Schedule

type Schedule interface {
	// Schedules can be used as Nexters, Recursively
	Nexter

	// process all scheduled tasks which should run specifically "at" the given
	// time. In practice, the "at" parameter will be the result of the previous
	// call of Next(...)
	Tick(runner taskrunner.TaskRunner, at time.Time) (map[string]*taskrunner.TaskStatus, error)
}

The Schedule controls when tasks are run. It is in charge of both determining when something needs to happen, and the actual passing of scheduled events to a TaskRunner. This allows a scheduler to independently decide not only when the "scheduled tasks" should be run, but also any retries, and anything to do with internal state manipulation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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