{"modulePath":"github.com/taskcluster/taskcluster-worker","version":"v0.1.20","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package taskrun\n\nPackage taskrun provides abstractions to execute a run of a task given a task, engine, plugin, and other runtime objects required by plugin and engine.\n\nThis 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.\n\n## Types\n\n```go\ntype AbortReason int\n```\nAn AbortReason specifies the reason a TaskRun was aborted.\n\n```go\nconst (\n\t// WorkerShutdown is used to abort a TaskRun because the worker is going to\n\t// shutdown immediately.\n\tWorkerShutdown AbortReason = 1 + iota\n\t// TaskCanceled is used to abort a TaskRun when the queue reports that the\n\t// task has been canceled, deadline exceeded or claim expired.\n\tTaskCanceled\n)\n```\n\n```go\ntype Options struct {\n\tEnvironment   runtime.Environment\n\tEngine        engines.Engine\n\tPluginManager *plugins.PluginManager\n\tMonitor       runtime.Monitor\n\tTaskInfo      runtime.TaskInfo\n\tPayload       map[string]interface{}\n\tQueue         client.Queue\n}\n```\nOptions required to create a TaskRun\n\n```go\ntype Stage int\n```\nA Stage represents the internal state at which a TaskRun has been advanced.\n\n```go\nconst (\n\tStagePrepare Stage = iota\n\tStageBuild\n\tStageStart\n\tStageStarted\n\tStageWaiting\n\tStageStopped\n\tStageFinished\n)\n```\nStages supported by RunStage\n\n```go\nfunc (s Stage) String() string\n```\n\n```go\ntype TaskRun struct {\n\t// contains filtered or unexported fields\n}\n```\nA TaskRun holds the state of a running task.\n\nMethods on this object is not thread-safe, with the exception of Abort() and SetQueueClient() which are intended to be called from other threads.\n\n```go\nfunc New(options Options) *TaskRun\n```\nNew returns a new TaskRun\n\n```go\nfunc (t *TaskRun) Abort(reason AbortReason)\n```\nAbort will interrupt task execution.\n\n```go\nfunc (t *TaskRun) Dispose() error\n```\nDispose will finish any final processing dispose of all resources.\n\nIf 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.\n\n```go\nfunc (t *TaskRun) RunToStage(targetStage Stage)\n```\nRunToStage will run all stages up-to and including the given stage.\n\nThis 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.\n\n```go\nfunc (t *TaskRun) SetCredentials(clientID, accessToken, certificate string)\n```\nSetCredentials is used to provide the task-specific temporary credentials, and update these whenever they change.\n\n```go\nfunc (t *TaskRun) SetQueueClient(queue client.Queue)\n```\nSetQueueClient will update the queue client exposed through the TaskContext.\n\nThis should be updated whenever the task is reclaimed.\n\n```go\nfunc (t *TaskRun) WaitForResult() (success bool, exception bool, reason runtime.ExceptionReason)\n```\nWaitForResult will run all stages up to and including StageFinished, before returning the resolution of the given TaskRun.\n\n","path":"github.com/taskcluster/taskcluster-worker/worker/taskrun","name":"taskrun","synopsis":"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.","isRedistributable":true}
