Parallel State

Parameter
Description
Type
Required

name

Unique State name. Must follow the Serverless Workflow Naming Convention

string

yes

type

State type

string

yes

branches

List of branches for this parallel state

array

yes

completionType

Option types on how to complete branch execution. Default is "allOf"

enum

no

numCompleted

Used when branchCompletionType is set to atLeast to specify the least number of branches that must complete in order for the state to transition/end.

string or number

yes (if completionType is atLeast)

timeouts

State specific timeout settings

object

no

stateDataFilter

State data filter

object

no

onErrors

States error handling and retries definitions

array

no

transition

Next transition of the workflow after all branches have completed execution

string or object

yes (if end is not defined)

compensatedBy

Unique name of a workflow state which is responsible for compensation of this state

string

no

usedForCompensation

If true, this state is used to compensate another state. Default is false

boolean

no

metadata

Metadata information

object

no

end

Is this state an end state

boolean or object

yes (if transition is not defined)

Example:

JSON
YAML
 {
     "name":"parallel-exec",
     "type":"parallel",
     "completionType": "allOf",
     "branches": [
        {
          "name": "branch-1",
          "actions": [
            {
                "functionRef": {
                    "refName": "function-name-one",
                    "arguments": {
                        "order": "${ .someParam }"
                    }
                }
            }
        ]
        },
        {
          "name": "branch-2",
          "actions": [
              {
                  "functionRef": {
                      "refName": "function-name-two",
                      "arguments": {
                          "order": "${ .someParam }"
                      }
                  }
              }
          ]
        }
     ],
     "end": true
}
name: parallel-exec
type: parallel
completionType: allOf
branches:
- name: branch-1
  actions:
  - functionRef:
      refName: function-name-one
      arguments:
        order: "${ .someParam }"
- name: branch-2
  actions:
  - functionRef:
      refName: function-name-two
      arguments:
        order: "${ .someParam }"
end: true

Parallel state defines a collection of branches that are executed in parallel. A parallel state can be seen a state which splits up the current workflow instance execution path into multiple ones, one for each branch. These execution paths are performed in parallel and are joined back into the current execution path depending on the defined completionType parameter value.

The "completionType" enum specifies the different ways of completing branch execution:

  • allOf: All branches must complete execution before the state can transition/end. This is the default value in case this parameter is not defined in the parallel state definition.

  • atLeast: State can transition/end once at least the specified number of branches have completed execution. In this case you must also specify the numCompleted property to define this number.

Exceptions may occur during execution of branches of the Parallel state, this is described in detail in this section.

The timeouts property can be used to set state specific timeout settings. Parallel states can define the stateExecTimeout and branchExecTimeout timeout settings. For more information on workflow timeouts reference the Workflow Timeouts section.

Note that transition and end properties are mutually exclusive, meaning that you cannot define both of them at the same time.

Last updated