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 ¶
- type AbortReason
- type Options
- type Stage
- type TaskRun
- func (t *TaskRun) Abort(reason AbortReason)
- func (t *TaskRun) Dispose() error
- func (t *TaskRun) RunToStage(targetStage Stage)
- func (t *TaskRun) SetCredentials(clientID, accessToken, certificate string)
- func (t *TaskRun) SetQueueClient(queue client.Queue)
- func (t *TaskRun) WaitForResult() (success bool, exception bool, reason runtime.ExceptionReason)
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.
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 (*TaskRun) Abort ¶
func (t *TaskRun) Abort(reason AbortReason)
Abort will interrupt task execution.
func (*TaskRun) Dispose ¶
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 ¶
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
SetCredentials is used to provide the task-specific temporary credentials, and update these whenever they change.
func (*TaskRun) SetQueueClient ¶
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.