EachParallel
type: "io.kestra.core.tasks.flows.EachParallel"
Execute a task for a list of values in parallel.
For each value
, the tasks
list will be executed
The value must be valid json string representing an arrays, like ["value1", "value2"]
or [{"key":"value1"}, {"key":"value2"}]
or an array of valid JSON strings.
The current value is available on the variable null
.
The task list will be executed in parallel, for example if you have a 3 values with 2 tasks, all the 6 tasks will be computed in parallel without any guarantee on the order.
If you want to have each value in parallel, but no concurrent task for each value, you need to wrap the tasks with a Sequential
tasks
Examples
id: "each_parallel"
type: "io.kestra.core.tasks.flows.EachParallel"
value: '["value 1", "value 2", "value 3"]'
tasks:
- id: each-value
type: io.kestra.core.tasks.debugs.Return
format: "{{ task.id }} with current value '{{ taskrun.value }}'"
id: "each_parallel"
type: "io.kestra.core.tasks.flows.EachParallel"
value:
- value 1
- value 2
- value 3
tasks:
- id: each-value
type: io.kestra.core.tasks.debugs.Return
format: "{{ task.id }} with current value '{{ taskrun.value }}'"
Handling each value in parallel but only 1 child task for each value at the same time.
id: "each_parallel"
type: "io.kestra.core.tasks.flows.EachParallel"
value: '["value 1", "value 2", "value 3"]'
tasks:
- id: seq
type: io.kestra.core.tasks.flows.Sequential
tasks:
- id: t1
type: io.kestra.core.tasks.scripts.Bash
commands:
- 'echo "{{task.id}} > {{ parents[0].taskrun.value }}
- 'sleep 1'
- id: t2
type: io.kestra.core.tasks.scripts.Bash
commands:
- 'echo "{{task.id}} > {{ parents[0].taskrun.value }}
- 'sleep 1'
Properties
concurrent
- Type: integer
- Dynamic: ❌
- Required: ✔️
- Default:
0
Number of concurrent parallel tasks
If the value is 0
, no limit exist and all the tasks will start at the same time
tasks
- Type: array
- SubType: Task
- Dynamic: ❌
- Required: ✔️
- Min items:
1
value
- Type:stringarray
- Dynamic: ✔️
- Required: ✔️
The list of values for this task
The value car be passed as a String, a list of String, or a list of objects
errors
- Type: array
- SubType: Task
- Dynamic: ❌
- Required: ❌
List of tasks to run if any tasks failed on this FlowableTask