worker

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2017 License: MPL-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package worker is responsible for managing the claiming, executing, and resolution of tasks. This package consists of two key components:

Task Manager - this component is responsible for the claiming, executing and resolution of tasks. It also is responsible for cancelling tasks that run beyond their max runtime as well as for when a cancellation action was triggered by an external entity.

Queue Service - The queue service will retrieve and attempt to claim as many tasks as specified from the Azure task queues. The service will attempt to poll from the highest priority queues first, followed by lower priority queues until as many tasks can be claimed up to the limit set.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigSchema

func ConfigSchema() schematypes.Object

ConfigSchema returns the configuration schema for the worker.

Types

type Manager

type Manager struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Manager is resonsible for managing the entire task lifecyle from claiming the task, creating a sandbox environment, and reporting the results fo the execution. The manager will also be responsible for ensuring tasks do not run past their max run time and are aborted if a cancellation message is received.

func (*Manager) CancelTask

func (m *Manager) CancelTask(taskID string, runID int)

CancelTask will cancel a running task. Typically this will be called when a Pulse message is received to cancel a task. Calling this method will not resolve the task as it's assumed that this task was already resolved as cancelled by another system/client.

func (*Manager) RunningTasks

func (m *Manager) RunningTasks() []string

RunningTasks returns the list of task names that are currently running. This could be useful for determining the number of tasks currently running or snapshotting the current running task list at a moment in time.

func (*Manager) Start

func (m *Manager) Start()

Start will instruct the queue service to begin claiming work and will run task claims that are returned by the queue service.

func (*Manager) Stop

func (m *Manager) Stop()

Stop should be called when the worker should gracefully end the execution of all running tasks before completely shutting down.

type QueueService

type QueueService interface {
	Done()
	Start() <-chan *taskClaim
	Stop()
}

QueueService is an interface describing the methods responsible for claiming work from Azure queues.

type TaskRun

type TaskRun struct {
	// Static properties
	TaskID string
	RunID  int
	// contains filtered or unexported fields
}

TaskRun represents the task lifecycle once claimed. TaskRun contains information about the task as well as controllers for executing and resolving the task.

func (*TaskRun) Abort

func (t *TaskRun) Abort()

Abort will set the status of the task to aborted and abort the task execution environment if one has been created.

func (*TaskRun) Cancel

func (t *TaskRun) Cancel()

Cancel will set the status of the task to cancelled and abort the task execution environment if one has been created.

func (*TaskRun) Run

func (t *TaskRun) Run()

Run is the entrypoint to executing a task run. The task payload will be parsed, plugins created, and the task will run through each of the stages of the task life cycle.

Tasks that do not complete successfully will be reported as an exception during the exceptionStage.

type Worker

type Worker struct {
	// contains filtered or unexported fields
}

Worker is the center of taskcluster-worker and is responsible for managing resources, tasks, and host level events.

func New

func New(config interface{}, log *logrus.Logger) (*Worker, error)

New will create a worker given configuration matching the schema from ConfigSchema(). The log parameter is optional and if nil is given a default logrus logger will be used.

func (*Worker) PayloadSchema

func (w *Worker) PayloadSchema() schematypes.Object

PayloadSchema returns the payload schema for this worker.

func (*Worker) Start

func (w *Worker) Start()

Start will begin the worker cycle of claiming and executing tasks. The worker will also being to respond to host level events such as shutdown notifications and resource depletion events.

func (*Worker) Stop

func (w *Worker) Stop()

Stop is a convenience method for stopping the worker loop. Usually the worker will not be stopped this way, but rather will listen for a shutdown event.

Jump to

Keyboard shortcuts

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