This topic describes the parallel step and provides an example.
Introduction
A parallel step executes multiple branches in parallel. Each branch contains a series of sequential steps.
Each branch of a parallel step has a local variable. When a parallel step runs, it executes all branches concurrently. The sequential steps in each branch modify the local variable of that branch. After all branches finish executing, an output mapping transforms the array of local variables from the branches into the output for the parallel step.
A parallel step has the following properties:
- (Required) type: The type of the step. The value must be parallel.
- (Required) name: The name of the step.
- (Required) branches: An array of branches.
(Required) steps: Defines the sequential steps for the branch.
- (Optional) end: Specifies whether this is the last step in the flow.
- (Optional) inputMappings: The input mappings.
- (Optional) outputMappings: The output mappings. The
$localvariable for this step is an array. Each element in the array is a JSON object that contains the execution result of a branch.Note If output mappings are not specified, the output of this step is empty by default.
Example
The following example flow defines a parallel step. This parallel step contains two branches, and each branch contains a pass step.
version: v1
type: flow
steps:
- type: parallel
name: myparallel
branches:
- steps:
- type: pass
name: pass1
outputMappings:
- target: result
source: pass1
- steps:
- type: pass
name: pass2
outputMappings:
- target: result
source: pass2
outputMappings:
- target: result
source: $local[*].result pass1is defined as follows.{ "result": "pass1" }pass2is defined as follows.{ "result": "pass2" }myparallelis defined as follows.{ "result": ["pass1", "pass2"] }