tasks

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2018 License: GPL-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 implements a basic dispatcher for tasks. Each task is simply a go routine that will do something in the background

func NewScheduler

func NewScheduler(interval uint) (*Scheduler, error)

NewScheduler initialize a new scheduler.

func (*Scheduler) RegisterTask

func (s *Scheduler) RegisterTask(task SchedulerTask) error

RegisterTask adds the task to the task queue of the scheduler. All tasks in this queue will be started later.

func (*Scheduler) StartTasks

func (s *Scheduler) StartTasks(ctx context.Context) error

StartTasks starts each previously registered task. The starting will be done parallel.

type SchedulerTask

type SchedulerTask interface {
	Name() string
	Run(ctx context.Context) error
}

A SchedulerTask handles different tasks (jobs) in the background.

type TaskInstrumenting

type TaskInstrumenting struct {
	Next SchedulerTask
}

TaskInstrumenting implements a Prometheus instrumenting around regular SchedulerTask(s).

func (*TaskInstrumenting) Name

func (ti *TaskInstrumenting) Name() string

Name returns the name of the underlaying task.

func (*TaskInstrumenting) Run

func (ti *TaskInstrumenting) Run(ctx context.Context) error

Run exports metrics of the current task and executes the underlaying task.

type TaskLogger

type TaskLogger struct {
	Next SchedulerTask
}

TaskLogger implements logging functions around regular SchedulerTask(s).

func (*TaskLogger) Name

func (tl *TaskLogger) Name() string

Name returns the name of the underlaying task.

func (*TaskLogger) Run

func (tl *TaskLogger) Run(ctx context.Context) error

Run logs the current task and executes the underlaying task.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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