scheduler

package
v0.0.0-...-b7fae21 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scheduler

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

Scheduler is a struct that defines an instance of a scheduler. It holds the tasks (`[]*tasks`).

func New

func New() *Scheduler

New returns a new empty scheduler. To this scheduler one would need to add tasks using `NewTask` and then start it using `Start`

s := scheduler.New()
s.NewTask("* * * * *", func() { fmt.Println("Hello, world") })
s.Start()

func (*Scheduler) NewTask

func (s *Scheduler) NewTask(cronfmt string, fn func()) error

NewTask adds a new scheduler task. It receives a cron formatted string and a function of the type `TaskFunc` that's defined in this package.

func (*Scheduler) Start

func (s *Scheduler) Start() error

Start starts the scheduler. This should be called after adding tasks using NewTask, as it's currently impossible to add tasks to an already started scheduler.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

type TaskFunc

type TaskFunc func()

TaskFunc is the function type that should be used when adding tasks to the scheduler

Jump to

Keyboard shortcuts

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