tasks

package
v0.0.0-...-94511c4 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DEBUG = (os.Getenv("D") == "1")

check if the debug flag is set

Functions

func Init

func Init()

Initialize all required components.

func RegisterAllTasks

func RegisterAllTasks()

Register all known tasks in the system.

func RegisterTask

func RegisterTask(t Task)

Register a single task in the scheduler and the registered Task array.

func Start

func Start()

Start the scheduler.

Types

type Task

type Task struct {
	Name     string
	Slug     string
	Interval time.Duration
	Function func(*TaskContext)
	// contains filtered or unexported fields
}

Register the general task informations.

func (*Task) Init

func (t *Task) Init()

Initialize all task values.

func (Task) Run

func (t Task) Run()

Wrap the task function in a warpper.

type TaskContext

type TaskContext struct {
	Task      *Task
	Logger    *log.Logger
	StartTime time.Time
}

The context a execution is runnung in

func (*TaskContext) Debug

func (c *TaskContext) Debug(message string, v ...interface{})

Alias the debug function

func (*TaskContext) Err

func (c *TaskContext) Err(message string, v ...interface{})

Alias the error function

func (*TaskContext) Info

func (c *TaskContext) Info(message string, v ...interface{})

Alias the info function

func (*TaskContext) TaskSlug

func (c *TaskContext) TaskSlug() string

Create a lower case, non special symbol, no space string

func (*TaskContext) Warn

func (c *TaskContext) Warn(message string, v ...interface{})

Alias the warning function

Jump to

Keyboard shortcuts

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