runtasks

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: GPL-3.0 Imports: 7 Imported by: 0

README

run_tasks Task

Description

The run_tasks task executes a series of specified tasks sequentially. This is particularly useful for scenarios where tasks need to be performed in a specific order, with the outcome of one potentially affecting the subsequent ones.

Task Behavior
  • The task starts the child tasks one after the other in the order they are listed.
  • It continuously monitors the result of the currently running child task. As soon as the child task returns a "success" or "failure" result, the execution of that task is stopped.
  • After cancelling the current task, the run_tasks task then initiates the next task in the sequence.

An important aspect of this task is that it cancels tasks once they return a result. This is particularly significant for check tasks, which, by their nature, would continue running indefinitely according to their logic. In this sequential setup, however, they are stopped once they achieve a result, allowing the sequence to proceed.

Configuration Parameters

  • tasks:
    An array of tasks to be executed one after the other. Each task is defined according to the standard task structure.

  • stopChildOnResult:
    If set to true, each child task in the sequence is stopped as soon as it sets a result (either "success" or "failure"). This ensures that once a task has reached a outcome, it does not continue to run unnecessarily, allowing the next task in the sequence to commence.

  • expectFailure:
    If set to true, this option expects each task in the sequence to fail. The task sequence stops with a "failure" result if any task does not fail as expected.

  • continueOnFailure:
    When true, the sequence of tasks continues even if individual tasks fail, allowing the entire sequence to be executed regardless of individual task outcomes.

Defaults

Default settings for the run_tasks task:

- name: run_tasks
  config:
    tasks: []
    stopChildOnResult: true
    expectFailure: false
    continueOnFailure: false

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskName       = "run_tasks"
	TaskDescriptor = &types.TaskDescriptor{
		Name:        TaskName,
		Description: "Run tasks sequentially.",
		Config:      DefaultConfig(),
		NewTask:     NewTask,
	}
)

Functions

func NewTask

func NewTask(ctx *types.TaskContext, options *types.TaskOptions) (types.Task, error)

Types

type Config

type Config struct {
	Tasks             []helper.RawMessage `yaml:"tasks" json:"tasks"`
	StopChildOnResult bool                `yaml:"stopChildOnResult" json:"stopChildOnResult"`
	ExpectFailure     bool                `yaml:"expectFailure" json:"expectFailure"`
	ContinueOnFailure bool                `yaml:"continueOnFailure" json:"continueOnFailure"`
}

func DefaultConfig

func DefaultConfig() Config

func (*Config) Validate

func (c *Config) Validate() error

type Task

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

func (*Task) Config

func (t *Task) Config() interface{}

func (*Task) Description

func (t *Task) Description() string

func (*Task) Execute

func (t *Task) Execute(ctx context.Context) error

func (*Task) LoadConfig

func (t *Task) LoadConfig() error

func (*Task) Logger

func (t *Task) Logger() logrus.FieldLogger

func (*Task) Name

func (t *Task) Name() string

func (*Task) Timeout

func (t *Task) Timeout() time.Duration

func (*Task) Title

func (t *Task) Title() string

Jump to

Keyboard shortcuts

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