job

package
v0.0.0-...-f1cb1c4 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MaxYearsAhead int = 5

MaxYearsAhead is maximum years in future we will try to lookup

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	Id string
	// contains filtered or unexported fields
}

Job definition

func New

func New(id string, command func(), schedule []Schedule) (*Job, error)

New creates and returns new job struct.

func (*Job) LastRun

func (j *Job) LastRun() time.Time

func (*Job) Next

func (j *Job) Next(t time.Time) (time.Time, error)

Next returns the next time for job to start and error in case it didn't find the time (e.g. all Schedules expired)

func (*Job) NextRun

func (j *Job) NextRun() time.Time

Getters and Setters for private fields

func (*Job) Run

func (j *Job) Run()

Run starts Job command.

func (*Job) SetLastRun

func (j *Job) SetLastRun(t time.Time)

func (*Job) SetNextRun

func (j *Job) SetNextRun(t time.Time) (err error)

SetNextRun updates job nextRun field, which is actually used by Scheduler

func (*Job) String

func (j *Job) String() string

type Schedule

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

Schedule struct is numeric representation of already parsed ScheduleSpec and is used during scheduling

func NewSchedule

func NewSchedule(spec ScheduleSpec) (s Schedule, err error)

New creates Schedule with all available variants in numeric form from string based ScheduleSpec It sets sane defaults in case any entry is missing, but Minute, Hour, Day, Month must be specified. Year by default is * - "every year". Second by default is 0. Default Timezone (Location) - Local.

func (*Schedule) Next

func (s *Schedule) Next(t time.Time) (time.Time, error)

Next returns schedule next time to run

func (Schedule) String

func (s Schedule) String() string

type ScheduleSpec

type ScheduleSpec struct {
	Second, Minute, Hour, Day, Weekday, Month, Year, Location string
}

ScheduleSpec defines time patterns to parse.

func (ScheduleSpec) String

func (s ScheduleSpec) String() string

Jump to

Keyboard shortcuts

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