runner

package module
v1.0.0-beta.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2021 License: MIT Imports: 14 Imported by: 0

README

runner

The duration based task runner for GoDash dashboard.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ISO8601 is the RegExp representation of an ISO8601 duration string (ex. P1Y2M3DT5H6M7S)
	ISO8601 = regexp.MustCompile(`(?i)P(?P<years>[\d\.]+Y)?(?P<months>[\d\.]+M)?(?P<days>[\d\.]+D)?T?(?P<hours>[\d\.]+H)?(?P<minutes>[\d\.]+M)?(?P<seconds>[\d\.]+?S)?`)
	// DurationMapping is the duration calculations for ISO8601
	DurationMapping = map[string]time.Duration{
		"years":   time.Hour * 24 * 365,
		"months":  time.Hour * 24 * 30,
		"days":    time.Hour * 24,
		"hours":   time.Hour,
		"minutes": time.Second * 60,
		"seconds": time.Second,
	}
)

Functions

This section is empty.

Types

type Identity

type Identity struct {
	MachineID string `json:"id"`
	Location  string `json:"location"`
}

Identity describes the server

type Runner

type Runner struct {
	RedisControl tasks.Redis
	Identity     Identity
	TaskList     *utils.OrderedItems
	Paused       bool

	OnResult func(tasks.Task, tasks.Result)
	// contains filtered or unexported fields
}

Runner describes the job runner instance

func NewRunner

func NewRunner(id Identity, list []tasks.Task, rc tasks.Redis, OnResult func(tasks.Task, tasks.Result), paused bool) *Runner

NewRunner creates a job runner instance

func (*Runner) Add

func (r *Runner) Add(t tasks.Task) *Runner

Add adds a job to the queue

func (*Runner) AddTasks

func (r *Runner) AddTasks(list []tasks.Task) *Runner

Add a slice of tasks to the Runner

func (*Runner) Hash

func (r *Runner) Hash(t tasks.Task) string

Hash generates a unique ID based on a task struct

func (*Runner) ParseDuration

func (r *Runner) ParseDuration(str string) (duration time.Duration)

ParseDuration converts ISO8601 to time.Duration

func (*Runner) Pause

func (r *Runner) Pause()

Pause temporarily pauses task execution

func (*Runner) Resume

func (r *Runner) Resume()

Resume restarts task execution

func (*Runner) Stop

func (r *Runner) Stop()

Stop cancels all running tasks

func (*Runner) Tasks

func (r *Runner) Tasks(name string) (out []tasks.CleanTask)

Tasks gets a list of current tasks and their last result output

Jump to

Keyboard shortcuts

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