scheduler

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidCronExpr = errors.New("invalid cron expression")
	ErrJobAlreadyExist = errors.New("job already exist")
	ErrJobNotFound     = errors.New("job not found")
	ErrAlreadyStarted  = errors.New("already started")
	ErrNotRunning      = errors.New("not running")
)

Errors.

Functions

This section is empty.

Types

type Job

type Job interface {
	Run()
}

Job is a job representation for the scheduler.

type Scheduler

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

Scheduler schedules jobs to run them at a given interval.

func New

func New() *Scheduler

New returns a scheduler.

func (*Scheduler) Add

func (s *Scheduler) Add(name string, j Job, interval time.Duration) error

Add adds a job in the scheduler. The job runs every interval duration when the scheduler is started or already running.

func (*Scheduler) AddCron

func (s *Scheduler) AddCron(name string, j Job, expr string) error

AddCron adds the job in the scheduler. The job will be run depending on the cron expression when the scheduler is started or already running.

func (*Scheduler) Remove

func (s *Scheduler) Remove(name string) error

Remove removes the job from the scheduler.

func (*Scheduler) Start

func (s *Scheduler) Start() error

Start starts the scheduler.

func (*Scheduler) Stop

func (s *Scheduler) Stop(ctx context.Context) error

Stop stops the scheduler.

Jump to

Keyboard shortcuts

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