taskrun

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2018 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package taskrun provides abstractions to execute a run of a task given a task, engine, plugin, and other runtime objects required by plugin and engine.

This package will report back the status that should be reported to the queue, but it will not undertake any interaction with the queue. Other than passing a queue object on to engines and plugins through the TaskContext.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AbortReason

type AbortReason int

An AbortReason specifies the reason a TaskRun was aborted.

const (
	// WorkerShutdown is used to abort a TaskRun because the worker is going to
	// shutdown immediately.
	WorkerShutdown AbortReason = 1 + iota
	// TaskCanceled is used to abort a TaskRun when the queue reports that the
	// task has been canceled, deadline exceeded or claim expired.
	TaskCanceled
)

type Options

type Options struct {
	Environment   runtime.Environment
	Engine        engines.Engine
	PluginManager *plugins.PluginManager
	Monitor       runtime.Monitor
	TaskInfo      runtime.TaskInfo
	Payload       map[string]interface{}
	Queue         client.Queue
}

Options required to create a TaskRun

type Stage

type Stage int

A Stage represents the internal state at which a TaskRun has been advanced.

const (
	StagePrepare Stage = iota
	StageBuild
	StageStart
	StageStarted
	StageWaiting
	StageStopped
	StageFinished
)

Stages supported by RunStage

func (Stage) String

func (s Stage) String() string

type TaskRun

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

A TaskRun holds the state of a running task.

Methods on this object is not thread-safe, with the exception of Abort() and SetQueueClient() which are intended to be called from other threads.

func New

func New(options Options) *TaskRun

New returns a new TaskRun

func (*TaskRun) Abort

func (t *TaskRun) Abort(reason AbortReason)

Abort will interrupt task execution.

func (*TaskRun) Dispose

func (t *TaskRun) Dispose() error

Dispose will finish any final processing dispose of all resources.

If there was an unhandled error Dispose() returns either runtime.ErrFatalInternalError or runtime.ErrNonFatalInternalError. Any other error is reported/logged and runtime.ErrFatalInternalError is returned instead.

func (*TaskRun) RunToStage

func (t *TaskRun) RunToStage(targetStage Stage)

RunToStage will run all stages up-to and including the given stage.

This will not rerun previous stages, the TaskRun structure always knows what stage it has executed. This is only useful for testing, the WaitForResult() method will run all stages before returning.

func (*TaskRun) SetCredentials added in v0.1.3

func (t *TaskRun) SetCredentials(clientID, accessToken, certificate string)

SetCredentials is used to provide the task-specific temporary credentials, and update these whenever they change.

func (*TaskRun) SetQueueClient

func (t *TaskRun) SetQueueClient(queue client.Queue)

SetQueueClient will update the queue client exposed through the TaskContext.

This should be updated whenever the task is reclaimed.

func (*TaskRun) WaitForResult

func (t *TaskRun) WaitForResult() (success bool, exception bool, reason runtime.ExceptionReason)

WaitForResult will run all stages up to and including StageFinished, before returning the resolution of the given TaskRun.

Jump to

Keyboard shortcuts

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