cron

package
v0.4.6 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCannotRunInPast           = fmt.Errorf("cron: could not run a task in the past")
	ErrInfiniteRunWithNoInterval = fmt.Errorf("cron: could not run a task recurrently without interval")
)

Functions

This section is empty.

Types

type Job

type Job struct {
	Id       string
	Every    *time.Duration
	MaxRun   *uint
	StartsAt *time.Time
	EndsAt   *time.Time
	LastRun  time.Time
	NextRun  time.Time
	// contains filtered or unexported fields
}

type JobFunc

type JobFunc func(*Job) error

type JobOnError

type JobOnError func(error)

type Scheduler

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

func NewScheduler

func NewScheduler() *Scheduler

func (*Scheduler) GetById

func (s *Scheduler) GetById(id string) *Job

func (*Scheduler) RunEvery

func (s *Scheduler) RunEvery(id string, f JobFunc, duration time.Duration) error

func (*Scheduler) RunOnce

func (s *Scheduler) RunOnce(id string, f JobFunc, t time.Time) error

func (*Scheduler) Schedule

func (s *Scheduler) Schedule(f JobFunc, option *TaskDefinition, options ...*TaskDefinition) error

func (*Scheduler) SetOnError

func (s *Scheduler) SetOnError(e JobOnError)

func (*Scheduler) Start

func (s *Scheduler) Start()

func (*Scheduler) Timeout

func (s *Scheduler) Timeout(id string, f JobFunc, timeout time.Duration) error

func (*Scheduler) Unschedule

func (s *Scheduler) Unschedule(id string)

type TaskDefinition added in v0.4.0

type TaskDefinition struct {
	Id                   string
	Every                *time.Duration
	LimitRun             *uint
	StartAt              *time.Time
	EndsAt               *time.Time
	MaxConcurrentJob     *uint
	MaxConcurrentJobWait *bool
}

Jump to

Keyboard shortcuts

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