tasks

package
v3.0.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2018 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CancelTask

func CancelTask(kv *api.KV, taskID string) error

CancelTask marks a task as Canceled

func CheckTaskStepStatusChange

func CheckTaskStepStatusChange(before, after string) (bool, error)

CheckTaskStepStatusChange checks if a status change is allowed

func DeleteTask

func DeleteTask(kv *api.KV, taskID string) error

DeleteTask allows to delete a stored task

func EmitTaskEvent deprecated

func EmitTaskEvent(kv *api.KV, deploymentID, taskID string, taskType TaskType, status string) (string, error)

EmitTaskEvent emits a task event based on task type

Deprecated: use EmitTaskEventWithContextualLogs instead

func EmitTaskEventWithContextualLogs

func EmitTaskEventWithContextualLogs(ctx context.Context, kv *api.KV, deploymentID, taskID string, taskType TaskType, status string) (string, error)

EmitTaskEventWithContextualLogs emits a task event based on task type

func GetInstances

func GetInstances(kv *api.KV, taskID, deploymentID, nodeName string) ([]string, error)

GetInstances retrieve instances in the context of this task.

Basically it checks if a list of instances is defined for this task for example in case of scaling. If not found it will returns the result of deployments.GetNodeInstancesIds(kv, deploymentID, nodeName).

func GetQueryTaskIDs

func GetQueryTaskIDs(kv *api.KV, taskType TaskType, query string, target string) ([]string, error)

GetQueryTaskIDs returns an array of taskID query-typed, optionally filtered by query and target

func GetTaskCreationDate

func GetTaskCreationDate(kv *api.KV, taskID string) (time.Time, error)

GetTaskCreationDate retrieves the creationDate of a task

func GetTaskData

func GetTaskData(kv *api.KV, taskID, dataName string) (string, error)

GetTaskData retrieves data for tasks

func GetTaskInput

func GetTaskInput(kv *api.KV, taskID, inputName string) (string, error)

GetTaskInput retrieves inputs for tasks

func GetTaskRelatedNodes

func GetTaskRelatedNodes(kv *api.KV, taskID string) ([]string, error)

GetTaskRelatedNodes returns the list of nodes that are specifically targeted by this task

Currently it only appens for scaling tasks

func GetTaskResultSet

func GetTaskResultSet(kv *api.KV, taskID string) (string, error)

GetTaskResultSet retrieves the task related resultSet in json string format

If no resultSet is found, nil is returned instead

func GetTaskTarget

func GetTaskTarget(kv *api.KV, taskID string) (string, error)

GetTaskTarget retrieves the targetID of a task

func GetTasksIdsForTarget

func GetTasksIdsForTarget(kv *api.KV, targetID string) ([]string, error)

GetTasksIdsForTarget returns IDs of tasks related to a given targetID

func IsAnotherLivingTaskAlreadyExistsError

func IsAnotherLivingTaskAlreadyExistsError(err error) (bool, string)

IsAnotherLivingTaskAlreadyExistsError checks if an error is due to the fact that another task is currently running If true, it returns the taskID of the currently running task

func IsTaskDataNotFoundError

func IsTaskDataNotFoundError(err error) bool

IsTaskDataNotFoundError checks if an error is a task data not found error

func IsTaskRelatedNode

func IsTaskRelatedNode(kv *api.KV, taskID, nodeName string) (bool, error)

IsTaskRelatedNode checks if the given nodeName is declared as a task related node

func ResumeTask

func ResumeTask(kv *api.KV, taskID string) error

ResumeTask marks a task as Initial to allow it being resumed

func TargetHasLivingTasks

func TargetHasLivingTasks(kv *api.KV, targetID string) (bool, string, string, error)

TargetHasLivingTasks checks if a targetID has associated tasks in status INITIAL or RUNNING and returns the id and status of the first one found

Only Deploy, UnDeploy, ScaleOut, ScaleIn and Purge task type are considered.

func TaskExists

func TaskExists(kv *api.KV, taskID string) (bool, error)

TaskExists checks if a task with the given taskID exists

func UpdateTaskStepStatus

func UpdateTaskStepStatus(kv *api.KV, taskID string, step *TaskStep) error

UpdateTaskStepStatus allows to update the task step status

Types

type Collector

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

A Collector is used to register new tasks in Yorc

func NewCollector

func NewCollector(consulClient *api.Client) *Collector

NewCollector creates a Collector

func (*Collector) RegisterTask

func (c *Collector) RegisterTask(targetID string, taskType TaskType) (string, error)

RegisterTask register a new Task of a given type.

The task id is returned. Basically this is a shorthand for RegisterTaskWithData(targetID, taskType, nil)

func (*Collector) RegisterTaskWithData

func (c *Collector) RegisterTaskWithData(targetID string, taskType TaskType, data map[string]string) (string, error)

RegisterTaskWithData register a new Task of a given type with some data

The task id is returned.

type TaskStatus

type TaskStatus int

TaskStatus x ENUM( INITIAL, RUNNING, DONE, FAILED, CANCELED )

const (
	// TaskStatusINITIAL is a TaskStatus of type INITIAL
	TaskStatusINITIAL TaskStatus = iota
	// TaskStatusRUNNING is a TaskStatus of type RUNNING
	TaskStatusRUNNING
	// TaskStatusDONE is a TaskStatus of type DONE
	TaskStatusDONE
	// TaskStatusFAILED is a TaskStatus of type FAILED
	TaskStatusFAILED
	// TaskStatusCANCELED is a TaskStatus of type CANCELED
	TaskStatusCANCELED
)

func GetTaskStatus

func GetTaskStatus(kv *api.KV, taskID string) (TaskStatus, error)

GetTaskStatus retrieves the TaskStatus of a task

func ParseTaskStatus

func ParseTaskStatus(name string) (TaskStatus, error)

ParseTaskStatus attempts to convert a string to a TaskStatus

func (TaskStatus) String

func (x TaskStatus) String() string

String implements the Stringer interface.

type TaskStep

type TaskStep struct {
	Name   string `json:"name"`
	Status string `json:"status"`
}

TaskStep represents a step related to the task

func GetTaskRelatedSteps

func GetTaskRelatedSteps(kv *api.KV, taskID string) ([]TaskStep, error)

GetTaskRelatedSteps returns the steps of the related workflow

func TaskStepExists

func TaskStepExists(kv *api.KV, taskID, stepID string) (bool, *TaskStep, error)

TaskStepExists checks if a task step exists with a stepID and related to a given taskID and returns it

type TaskStepStatus

type TaskStepStatus int

TaskStepStatus x ENUM( INITIAL, RUNNING, DONE, ERROR, CANCELED )

const (
	// TaskStepStatusINITIAL is a TaskStepStatus of type INITIAL
	TaskStepStatusINITIAL TaskStepStatus = iota
	// TaskStepStatusRUNNING is a TaskStepStatus of type RUNNING
	TaskStepStatusRUNNING
	// TaskStepStatusDONE is a TaskStepStatus of type DONE
	TaskStepStatusDONE
	// TaskStepStatusERROR is a TaskStepStatus of type ERROR
	TaskStepStatusERROR
	// TaskStepStatusCANCELED is a TaskStepStatus of type CANCELED
	TaskStepStatusCANCELED
)

func ParseTaskStepStatus

func ParseTaskStepStatus(name string) (TaskStepStatus, error)

ParseTaskStepStatus attempts to convert a string to a TaskStepStatus

func (TaskStepStatus) String

func (x TaskStepStatus) String() string

String implements the Stringer interface.

type TaskType

type TaskType int

TaskType x ENUM( Deploy, UnDeploy, ScaleOut, ScaleIn, Purge, CustomCommand, CustomWorkflow, Query )

const (
	// TaskTypeDeploy is a TaskType of type Deploy
	TaskTypeDeploy TaskType = iota
	// TaskTypeUnDeploy is a TaskType of type UnDeploy
	TaskTypeUnDeploy
	// TaskTypeScaleOut is a TaskType of type ScaleOut
	TaskTypeScaleOut
	// TaskTypeScaleIn is a TaskType of type ScaleIn
	TaskTypeScaleIn
	// TaskTypePurge is a TaskType of type Purge
	TaskTypePurge
	// TaskTypeCustomCommand is a TaskType of type CustomCommand
	TaskTypeCustomCommand
	// TaskTypeCustomWorkflow is a TaskType of type CustomWorkflow
	TaskTypeCustomWorkflow
	// TaskTypeQuery is a TaskType of type Query
	TaskTypeQuery
)

func GetTaskType

func GetTaskType(kv *api.KV, taskID string) (TaskType, error)

GetTaskType retrieves the TaskType of a task

func ParseTaskType

func ParseTaskType(name string) (TaskType, error)

ParseTaskType attempts to convert a string to a TaskType

func (TaskType) String

func (x TaskType) String() string

String implements the Stringer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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