This topic describes Succeed states and provides related examples.
Overview
A Succeed state is used to terminate a series of states before the series of states are executed. A Succeed state is similar to the return
statement in programming languages. In the typical definition of a flow, the next state is executed after the current state is complete. However, if the current state is a Succeed state, subsequent states are not executed.
A Succeed state ends all states in the scope to which the Succeed state belongs, and the flow proceeds to the scope at a higher level.
The following table describes the attributes that a Succeed state contains.
Attribute | Type | Required | Description | Example |
Name | string | Yes | The name of the state. | my state |
Description | string | No | The description of the state. | describe it here |
Type | string | Yes | The type of the state. | Succeed |
InputConstructor | map[string]any | No | The input constructor. | See InputConstructor. |
OutputConstructor | map[string]any | No | The output constructor. | See OutputConstructor. |
Example
The following sample flow uses a Succeed state to end a scope.
Type: StateMachine
Name: my-wkfl
SpecVersion: v1
StartAt: Parallel1
States:
- Type: Parallel
Name: Parallel1
End: true
Branches:
- StartAt: Succeed1
States:
- Type: Succeed
Name: Succeed1
OutputConstructor:
FieldA: 123
- StartAt: Pass2
States:
- Type: Pass
InputConstructor:
FieldA: 321
Name: Pass2
End: true
Compared with the example for a Parallel state, the Pass1 state is replaced with the Succeed1 state in this example. Therefore, a Succeed state can be considered as a Pass state whose End attribute is true.
After Succeed1 is complete, the implicit ParallelBranch #0 is marked as complete.
After ParallelBranch #0 and ParallelBranch #1 are complete, Parallel1 is marked as complete. After Parallel1 is complete, the flow is marked as complete.