tasks

package
v4.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: Apache-2.0 Imports: 13 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CancelTask

func CancelTask(taskID string) error

CancelTask marks a task as Canceled

func CheckAndSetTaskErrorMessage added in v4.0.1

func CheckAndSetTaskErrorMessage(taskID, errorMessage string, overwriteExisting bool) error

CheckAndSetTaskErrorMessage sets a task related error message.

This function check for an existing message and overwrite it only if requested.

func CheckTaskStepStatusChange

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

CheckTaskStepStatusChange checks if a status change is allowed

func DeleteTask

func DeleteTask(taskID string) error

DeleteTask allows to delete a stored task

func EmitTaskEventWithContextualLogs

func EmitTaskEventWithContextualLogs(ctx context.Context, deploymentID, taskID string, taskType TaskType, workflowName, status string) (string, error)

EmitTaskEventWithContextualLogs emits a task event based on task type

func GetAllTaskData

func GetAllTaskData(taskID string) (map[string]string, error)

GetAllTaskData returns all registered data for a task

func GetInstances

func GetInstances(ctx context.Context, 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(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(taskID string) (time.Time, error)

GetTaskCreationDate retrieves the creationDate of a task

func GetTaskData

func GetTaskData(taskID, dataName string) (string, error)

GetTaskData retrieves data for tasks

func GetTaskErrorMessage

func GetTaskErrorMessage(taskID string) (string, error)

GetTaskErrorMessage retrieves the task related error message if any.

If no error message is found, an empty string is returned instead

func GetTaskInput

func GetTaskInput(taskID, inputName string) (string, error)

GetTaskInput retrieves inputs for tasks

func GetTaskOutput

func GetTaskOutput(taskID, outputName string) (string, error)

GetTaskOutput retrieves a specified output with name outputName for tasks

func GetTaskOutputs

func GetTaskOutputs(taskID string) (map[string]string, error)

GetTaskOutputs retrieves all outputs for tasks

func GetTaskRelatedNodes

func GetTaskRelatedNodes(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(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(taskID string) (string, error)

GetTaskTarget retrieves the targetID of a task

func GetTasksIdsForTarget deprecated

func GetTasksIdsForTarget(targetID string) ([]string, error)

GetTasksIdsForTarget returns IDs of tasks related to a given targetID

Deprecated: Prefer deployments.GetDeploymentTaskList() instead if possible

func HasLivingTasks added in v4.0.3

func HasLivingTasks(taskIDs []string, tasksTypesToIgnore []TaskType) (bool, string, string, error)

HasLivingTasks checks if the tasks list contains tasks in status INITIAL or RUNNING and returns the id and status of the first one found

The last argument specifies tasks types which should be ignored.

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 IsDeploymentRelatedTask added in v4.0.3

func IsDeploymentRelatedTask(tt TaskType) bool

IsDeploymentRelatedTask returns true if the task is related to a deployment

Typically query and action tasks are not necessary related to a deployment.

func IsStepRegistrationInProgress

func IsStepRegistrationInProgress(taskID string) (bool, error)

IsStepRegistrationInProgress checks if a task registration is still in progress, in which case it should not yet be executed

func IsTaskDataNotFoundError

func IsTaskDataNotFoundError(err error) bool

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

func IsTaskNotFoundError

func IsTaskNotFoundError(err error) bool

IsTaskNotFoundError checks if an error is a task not found error

func IsTaskRelatedNode

func IsTaskRelatedNode(taskID, nodeName string) (bool, error)

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

func IsWorkflowTask

func IsWorkflowTask(taskType TaskType) bool

IsWorkflowTask returns true if the task type is related to workflow

func MonitorTaskCancellation

func MonitorTaskCancellation(ctx context.Context, taskID string, f func())

MonitorTaskCancellation runs a routine that will constantly check if a given task is requested to be cancelled

If so and if the given f function is not nil then f is called and the routine stop itself. To stop this routine the given context should be cancelled.

func MonitorTaskFailure

func MonitorTaskFailure(ctx context.Context, taskID string, f func())

MonitorTaskFailure runs a routine that will constantly check if a given task is tagged as failed.

If so and if the given f function is not nil then f is called and the routine stop itself. To stop this routine the given context should be cancelled.

func NewAnotherLivingTaskAlreadyExistsError

func NewAnotherLivingTaskAlreadyExistsError(taskID, targetID, status string) error

NewAnotherLivingTaskAlreadyExistsError allows to create a new anotherLivingTaskAlreadyExistsError error

func NotifyErrorOnTask

func NotifyErrorOnTask(taskID string) error

NotifyErrorOnTask sets a flag that is used to notify task executors that a part of the task failed.

MonitorTaskFailure can be used to be notified.

func SetTaskData

func SetTaskData(taskID, dataName, dataValue string) error

SetTaskData sets a data in the task's context

func SetTaskDataList

func SetTaskDataList(taskID string, data map[string]string) error

SetTaskDataList sets a list of data into the task's context

func SetTaskErrorMessage

func SetTaskErrorMessage(taskID, errorMessage string) error

SetTaskErrorMessage sets a task related error message.

Set task error message even if it already contains a value. For a better control on gracefully setting this error message use CheckAndSetTaskErrorMessage

func StoreOperations

func StoreOperations(taskID string, operations api.KVTxnOps) error

StoreOperations stores operations related to a task through a transaction splitting this transaction if needed, in which case it will create a key notifying a registration is in progress

func TargetHasLivingTasks deprecated

func TargetHasLivingTasks(targetID string, tasksTypesToIgnore []TaskType) (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

The last argument specifies tasks types which should be ignored.

Deprecated: Prefer HasLivingTasks() instead

func TaskExists

func TaskExists(taskID string) (bool, error)

TaskExists checks if a task with the given taskID exists

func TaskHasCancellationFlag

func TaskHasCancellationFlag(taskID string) (bool, error)

TaskHasCancellationFlag check if a task has was flagged as canceled

func TaskHasErrorFlag

func TaskHasErrorFlag(taskID string) (bool, error)

TaskHasErrorFlag check if a task has was flagged as error

func UpdateTaskStepStatus

func UpdateTaskStepStatus(taskID string, step *TaskStep) error

UpdateTaskStepStatus allows to update the task step status

func UpdateTaskStepWithStatus

func UpdateTaskStepWithStatus(taskID, stepName string, status TaskStepStatus) error

UpdateTaskStepWithStatus allows to update the task step status

Types

type TaskStatus

type TaskStatus int

TaskStatus is an enumerated type for tasks statuses

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(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 a workflow

func GetTaskRelatedSteps

func GetTaskRelatedSteps(taskID string) ([]TaskStep, error)

GetTaskRelatedSteps returns the steps of the related workflow

func TaskStepExists

func TaskStepExists(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 is an enumerated type for tasks steps statuses

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 GetTaskStepStatus

func GetTaskStepStatus(taskID, stepName string) (TaskStepStatus, error)

GetTaskStepStatus returns the step status of the related step name

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 is an enumerated type for tasks

ENUM( Deploy UnDeploy ScaleOut ScaleIn Purge CustomCommand CustomWorkflow Query Action ForcePurge // ForcePurge is deprecated and should not be used anymore this stay here to prevent task renumbering colision AddNodes RemoveNodes )

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
	// TaskTypeAction is a TaskType of type Action
	TaskTypeAction
	// TaskTypeForcePurge is a TaskType of type ForcePurge
	// ForcePurge is deprecated and should not be used anymore this stay here to prevent task renumbering colision
	TaskTypeForcePurge
	// TaskTypeAddNodes is a TaskType of type AddNodes
	TaskTypeAddNodes
	// TaskTypeRemoveNodes is a TaskType of type RemoveNodes
	TaskTypeRemoveNodes
)

func GetTaskType

func GetTaskType(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