scheduler

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package scheduler implements a task scheduler for transactions.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorTaskAlreadyExists = fmt.Errorf("task already exists")
	ErrorNoSuchTask        = fmt.Errorf("no such task")
)

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name     string
	ID       int
	Schedule string
}

Entry is a scheduled entry

type Scheduler

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

Scheduler for transactions

func New

func New() (scheduler *Scheduler)

New creates a new scheduler

func (*Scheduler) AddTask

func (s *Scheduler) AddTask(name, schedule string, task Task) (err error)

AddTask to the scheduler

func (*Scheduler) AddTaskFunc

func (s *Scheduler) AddTaskFunc(name, schedule string, task func()) (err error)

AddTaskFunc is like AddTask but accepts a function task

func (*Scheduler) Entries

func (s *Scheduler) Entries() (entries []Entry)

Entries returns all current tasks from the scheduler

func (*Scheduler) RemoveTask

func (s *Scheduler) RemoveTask(name string) (err error)

RemoveTask from the scheduler

func (*Scheduler) Start

func (s *Scheduler) Start()

Start the scheduler

func (*Scheduler) Stop

func (s *Scheduler) Stop() (done context.Context)

Stop the scheduler. The returned context can be used to wait for all running jobs to finish.

type Task

type Task interface {
	Run()
}

Task represents a test task to be scheduled

type TaskFunc

type TaskFunc func()

TaskFunc is a scheduler task

func (TaskFunc) Run

func (t TaskFunc) Run()

Run implements Task interface

Jump to

Keyboard shortcuts

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