runtaskmatrix

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

README

run_task_matrix Task

Description

The run_task_matrix task is designed to execute a specified task multiple times, each with different input values drawn from an array. This task is ideal for scenarios where you need to test a task under various conditions or with different sets of data.

Task Behavior
  • Creates one instance of the child task for each value in matrixValues.
  • Tasks can run sequentially (default) or concurrently with runConcurrent: true.
  • By default, waits for all task instances to complete.
  • The result is failure if any instance fails, success if all succeed.

Configuration Parameters

  • task:
    The definition of the task to be executed for each matrix value. This task is run repeatedly, once for each value in the matrixValues array, with the current value made accessible via the variable named in matrixVar.

  • matrixVar:
    The name of the variable to which the current matrix value is assigned for each child task. This allows the child task to access and use the specific value from the matrix.

  • matrixValues:
    An array of values that form the matrix. Each value in this array is used to run the child task with a different input.

  • runConcurrent:
    Determines whether the child tasks should run concurrently or sequentially. If true, all tasks run at the same time; if false (default), they run one after the other.

  • successThreshold:
    The number of child tasks that need to succeed for the overall task to be considered successful. A value of 0 (default) means all child tasks must succeed.

  • failureThreshold:
    The number of child tasks that need to fail before the overall task is considered failed. Default: 1 (any single failure causes overall failure).

  • stopOnThreshold:
    If set to true, remaining child tasks are cancelled when either the success or failure threshold is reached. If false (default), the task waits for all children to complete.

  • invertResult:
    If set to true, the final result is inverted: success becomes failure and failure becomes success. Default: false.

  • ignoreResult:
    If set to true, the task always returns success regardless of child task outcomes. Default: false.

Defaults

Default settings for the run_task_matrix task:

- name: run_task_matrix
  config:
    task: {}
    matrixVar: ""
    matrixValues: []
    runConcurrent: false
    successThreshold: 0
    failureThreshold: 1
    stopOnThreshold: false
    invertResult: false
    ignoreResult: false

Outputs

This task does not produce any outputs.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskName       = "run_task_matrix"
	TaskDescriptor = &types.TaskDescriptor{
		Name:        TaskName,
		Description: "Run a task multiple times based on an input array.",
		Category:    "flow-control",
		Config:      DefaultConfig(),
		Outputs:     []types.TaskOutputDefinition{},
		NewTask:     NewTask,
	}
)

Functions

func NewTask

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

Types

type Config

type Config struct {
	Task         *helper.RawMessageMasked `yaml:"task" json:"task" require:"A" desc:"The task template to execute for each matrix value."`
	MatrixVar    string                   `yaml:"matrixVar" json:"matrixVar" desc:"Variable name to bind each matrix value to during task execution."`
	MatrixValues []any                    `yaml:"matrixValues" json:"matrixValues" desc:"List of values to iterate over, executing the task for each."`

	// Whether to run tasks concurrently (default: false - sequential)
	RunConcurrent bool `yaml:"runConcurrent" json:"runConcurrent" desc:"If true, run all matrix tasks concurrently instead of sequentially."`

	// Threshold behavior:
	// - 0 (default): No threshold - only evaluate result when ALL tasks complete
	// - >0: Set result when threshold is reached (but continue until all complete unless StopOnThreshold=true)
	SuccessThreshold uint64 `` /* 136-byte string literal not displayed */
	FailureThreshold uint64 `` /* 126-byte string literal not displayed */

	// Early termination - if true, stop immediately when a threshold is reached
	// Default: false - always wait for all tasks to complete
	StopOnThreshold bool `` /* 140-byte string literal not displayed */

	// Result transformation
	InvertResult bool `yaml:"invertResult" json:"invertResult" desc:"If true, swap success and failure results."`
	IgnoreResult bool `yaml:"ignoreResult" json:"ignoreResult" desc:"If true, always report success regardless of child task results."`
}

func DefaultConfig

func DefaultConfig() Config

func (*Config) IsRunConcurrent

func (c *Config) IsRunConcurrent() bool

IsRunConcurrent returns whether the matrix tasks should run concurrently.

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) Execute

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

func (*Task) LoadConfig

func (t *Task) LoadConfig() error

func (*Task) Timeout

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

Jump to

Keyboard shortcuts

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