scheduler

package
v1.1.29 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidPeriod indicates that the rate specified for the task is not
	// valid.
	ErrInvalidPeriod = errors.New("invalid period")
)

Functions

This section is empty.

Types

type Logger

type Logger interface {
	Log(vals ...interface{}) error
}

Logger defines the log interface used by the Scheduler.

type Scheduler

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

Scheduler is responsible for scheduling and executing the maintenance tasks.

func NewScheduler

func NewScheduler(log Logger) *Scheduler

NewScheduler creates a new maintenance scheduler with given tasks.

func (*Scheduler) AddTask

func (s *Scheduler) AddTask(task Task, period time.Duration) error

AddTask adds a new task to the scheduler.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context) *sync.WaitGroup

Start makes the scheduler start executing its tasks. It accepts a context that, if cancelled, will make the Scheduler to gracefully stop, it returns a waiting group that can be used to to wait for the scheduler to finish.

type Task

type Task interface {
	Name() string
	Type() string
	Execute() error
}

Task represents a maintenance task.

Jump to

Keyboard shortcuts

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