scheduler

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: Apache-2.0 Imports: 9 Imported by: 3

README

package scheduler

This package is responsible of sending checks to the execution pipeline with an interval specified for any number of instance configurations coming along with any check. Only one Scheduler instance is supposed to run at any time and even if this is not a requirement, a use case for multiple schedulers didn't show up and therefore wasn't tested.

Scheduler

A Scheduler instance keeps a collection of time.Tickers associated to a list of check.Checks: every time the ticker fires, all the checks in that list are sent to the execution pipeline. Every queue runs in its own goroutine. The Scheduler expose an interface based on methods attached to the struct but the implementation makes use of channels to synchronize the queues and to talk with the scheduler loop to send commands like Run and Stop.

Once a scheduler is stopped, restarting it with Run is not expected to work. A new one should be instantiated and Run instead.

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 keeps things rolling. More docs to come...

func NewScheduler

func NewScheduler(checksPipe chan<- check.Check) *Scheduler

NewScheduler create a Scheduler and returns a pointer to it.

func (*Scheduler) Cancel

func (s *Scheduler) Cancel(id check.ID) error

Cancel remove a Check from the scheduled queue. If the check is not in the scheduler, this is a noop.

func (*Scheduler) Enter

func (s *Scheduler) Enter(check check.Check) error

Enter schedules a `Check`s for execution accordingly to the `Check.Interval()` value. If the interval is 0, the check is supposed to run only once.

func (*Scheduler) IsCheckScheduled

func (s *Scheduler) IsCheckScheduled(id check.ID) bool

IsCheckScheduled returns whether a check is in the schedule or not

func (*Scheduler) Run

func (s *Scheduler) Run()

Run is the Scheduler main loop. This doesn't block but waits for the queues to be ready before returning.

func (*Scheduler) Stop

func (s *Scheduler) Stop() error

Stop the scheduler, blocks until the scheduler is fully stopped.

Jump to

Keyboard shortcuts

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