scheduler

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: AGPL-3.0 Imports: 5 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 wraps an underlying scheduler to provide task tracking by unique string identifiers, so jobs may be cancelled with only an identifier.

func (*Scheduler) AddOnce

func (sch *Scheduler) AddOnce(id string, start time.Time, fn func(context.Context, time.Time)) bool

AddOnce schedules the given task to run at time, registered under the given ID. Returns false if task already exists for id.

func (*Scheduler) AddRecurring

func (sch *Scheduler) AddRecurring(id string, start time.Time, freq time.Duration, fn func(context.Context, time.Time)) bool

AddRecurring schedules the given task to return at given period, starting at given time, registered under given id. Returns false if task already exists for id.

func (*Scheduler) Cancel

func (sch *Scheduler) Cancel(id string) bool

Cancel attempts to cancel a scheduled task with id, returns false if no task found.

func (*Scheduler) Start

func (sch *Scheduler) Start() bool

Start attempts to start the scheduler. Returns false if already running.

func (*Scheduler) Stop

func (sch *Scheduler) Stop() bool

Stop attempts to stop scheduler, cancelling all running tasks. Returns false if not running.

Jump to

Keyboard shortcuts

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