tasks

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2019 License: MIT Imports: 3 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Task

type Task struct {
	Log *logrus.Entry
	// contains filtered or unexported fields
}

func (*Task) Stop

func (t *Task) Stop()

type TaskManager

type TaskManager struct {
	Log *logrus.Entry
	// contains filtered or unexported fields
}

func NewTaskManager

func NewTaskManager(log *logrus.Entry) *TaskManager

func (*TaskManager) NewTask

func (t *TaskManager) NewTask(f func(stop chan struct{})) error

func (*TaskManager) NewTickerTask

func (t *TaskManager) NewTickerTask(duration time.Duration, before func(stop chan struct{}), f func(stop, notifyStopped chan struct{})) error

NewTickerTask is a convenience function for making a new task that repeats some action once per e.g. second the before function gets called after the lock is obtained, but before the ticker starts. if you handle a message on the stop channel in f() you need to send a message on the notifyStopped channel because returning is not sufficient. Here, unlike in a regular task, simply returning means we're now going to wait till the next tick to run again.

Jump to

Keyboard shortcuts

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