tasks

package
v2.10.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_TASK_LIFE = maestroSpecs.MAX_TASK_LIFE
View Source
const RUNAWAY_THRESHOLD = 20
View Source
const TASK_COMPLETE_STEP = ^uint32(0)

Variables

This section is empty.

Functions

func CompleteTask

func CompleteTask(id string) (err error)

func EnqueTask

func EnqueTask(task *MaestroTask, ackHandler AckHandler, persistent bool) (err error)

Enqueu's the task into disk storage

func EnqueTasks

func EnqueTasks(thesetasks []*MaestroTask, persistent bool) (err error)

enques a Batch of Tasks.

func FailTask

func FailTask(id string, cause *maestroSpecs.APIError) (err error)

func GetTaskStatus

func GetTaskStatus(id string) (step uint32, ok bool)

func InitTaskManager

func InitTaskManager()

func IterateTask

func IterateTask(id string, cb UpdateTaskCB) (err error)

When a TaskHandler has finished a step of a task, the handler should call this. This will execute a call back which makes changes to the MaestroTask and automatically iterates the Step field

func MarkTaskStepAsExecuting

func MarkTaskStepAsExecuting(id string)

marks the current Step as Executing Used if a Task starts a new goroutine, or defers an operation This is automatically cleared by IterateTask

func New_taskFIFO

func New_taskFIFO(maxsize uint32) (ret *taskFIFO)

func RegisterHandler

func RegisterHandler(optype string, handler TaskHandler)

func RemoveTask

func RemoveTask(id string) error

func RestartStoredTasks

func RestartStoredTasks()

LoadFromStorage Loads all tasks which were queued into storage to be called on startup. This

func StartTaskManager

func StartTaskManager()

func TaskAckFailed

func TaskAckFailed(taskId string, err error)

Informs the TaskManager that a request ACK for specific Task failed to send or be recieved by the original caller of the Task This is typically a remote server. In this case, the TaskManager will again ask for an ACK at some point in the future

func TaskAckOK

func TaskAckOK(taskid string)

Informs the TaskManager that a request ACK for specific Task was successful sent and recieved by the original caller of the Task This is typically a remote server

func ValidateTask

func ValidateTask(task *MaestroTask) (err error)

Ensures the Task can be run by the TaskManager No error is good

Types

type AckHandler

type AckHandler interface {
	SendFinishedAck(task *MaestroTask) (err error)
	SendFailedAck(task *MaestroTask) (err error)
}

An AckHandler is another module which can Ack a particular Task When you EnqueTask you must provide a AckHandler for the task

type IfTaskCB

type IfTaskCB func(task *MaestroTask) bool

type MaestroTask

type MaestroTask struct {
	Id   string
	Src  string                 // identifies where the task came from
	Op   maestroSpecs.Operation // a generic Operation
	Step uint32                 // A step of 0 means the task has never been started
	// Steps after this are proprietary to the Task at hand
	TotalSteps   uint32 // the last step in the Task (so '2' if there are 2 steps, 0 is the first)
	StepProgress uint32 // 0-100 % of Step complete
	StepName     string

	CompleteTime int64

	Error *maestroSpecs.APIError // if the Task has failed, this is the associate error
	// contains filtered or unexported fields
}

func CreateNewBatchTasks

func CreateNewBatchTasks(ops []maestroSpecs.Operation, masterid string, src string) (ret []*MaestroTask, err error)

func CreateNewBatchTask(childtasks []*MaestroTask, masterid string, src string) (ret *MaestroTask, err error) {

func CreateNewTask

func CreateNewTask(op maestroSpecs.Operation, src string) (ret *MaestroTask, err error)

type TaskHandler

type TaskHandler interface {
	// Submits a Task into the Handler. It's work is b
	SubmitTask(task *MaestroTask) error
	ValidateTask(task *MaestroTask) error
}

A TaskHandler is another module which can handle a certain type of Task Examples are: imageManager.go and jobManager.go

type UpdateTaskCB

type UpdateTaskCB func(task *MaestroTask)

Jump to

Keyboard shortcuts

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