scheduler

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

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Error(...interface{})
	Info(...interface{})
	Debug(...interface{})
	Warn(...interface{})
}

type Scheduler

type Scheduler struct {
	Jobs []*job.Job
	// contains filtered or unexported fields
}

Scheduler is main type for running jobs

func New

func New(l Logger) *Scheduler

NewScheduler constructs scheduler

func (*Scheduler) AddJob

func (sr *Scheduler) AddJob(j *job.Job) error

AddJob is the wrapper to add a job, updates NextRun field in process. If a scheduler is already running, the job is added with custom function, passed to scheduler goroutine.

func (*Scheduler) GetJobs

func (sr *Scheduler) GetJobs() (jobs []job.Job)

GetJobs returns the list of jobs, registered in scheduler

func (*Scheduler) IsRunning

func (sr *Scheduler) IsRunning() bool

IsRunning returns scheduler running or not

func (*Scheduler) RemoveJob

func (sr *Scheduler) RemoveJob(name string) error

RemoveJob is the wrapper to remove job, returns error if job is not present If a scheduler is already running, the job is removed with custom function, passed to scheduler goroutine.

func (*Scheduler) Start

func (sr *Scheduler) Start()

Start scheduler asynchronously

func (*Scheduler) StartAndServe

func (sr *Scheduler) StartAndServe()

StartAndServe starsts scheduler with preliminary running check

func (*Scheduler) Stop

func (sr *Scheduler) Stop() context.Context

Stop stops the scheduler scheduler, caller gets context to either wait for running jobs to finish or cancel and exit.

Jump to

Keyboard shortcuts

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