Class StateMachineFragment
- All Implemented Interfaces:
IChainable,software.amazon.jsii.JsiiSerializable,software.constructs.IConstruct,software.constructs.IDependable
Example:
import software.amazon.awscdk.Stack;
import software.constructs.Construct;
import software.amazon.awscdk.services.stepfunctions.*;
public class MyJobProps {
private String jobFlavor;
public String getJobFlavor() {
return this.jobFlavor;
}
public MyJobProps jobFlavor(String jobFlavor) {
this.jobFlavor = jobFlavor;
return this;
}
}
public class MyJob extends StateMachineFragment {
public final State startState;
public final INextable[] endStates;
public MyJob(Construct parent, String id, MyJobProps props) {
super(parent, id);
Choice choice = new Choice(this, "Choice").when(Condition.stringEquals("$.branch", "left"), new Pass(this, "Left Branch")).when(Condition.stringEquals("$.branch", "right"), new Pass(this, "Right Branch"));
// ...
this.startState = choice;
this.endStates = choice.afterwards().getEndStates();
}
}
public class MyStack extends Stack {
public MyStack(Construct scope, String id) {
super(scope, id);
// Do 3 different variants of MyJob in parallel
Parallel parallel = new Parallel(this, "All jobs").branch(new MyJob(this, "Quick", new MyJobProps().jobFlavor("quick")).prefixStates()).branch(new MyJob(this, "Medium", new MyJobProps().jobFlavor("medium")).prefixStates()).branch(new MyJob(this, "Slow", new MyJobProps().jobFlavor("slow")).prefixStates());
StateMachine.Builder.create(this, "MyStateMachine")
.definitionBody(DefinitionBody.fromChainable(parallel))
.build();
}
}
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationModeNested classes/interfaces inherited from interface software.amazon.awscdk.services.stepfunctions.IChainable
IChainable.Jsii$DefaultNested classes/interfaces inherited from interface software.constructs.IConstruct
software.constructs.IConstruct.Jsii$Default -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedStateMachineFragment(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedStateMachineFragment(software.amazon.jsii.JsiiObjectRef objRef) protectedStateMachineFragment(software.constructs.Construct scope, String id) Creates a new construct node. -
Method Summary
Modifier and TypeMethodDescriptionThe states to chain onto if this fragment is used.getId()Descriptive identifier for this chainable.abstract StateThe start state of this state machine fragment.next(IChainable next) Continue normal execution with the given state.Prefix the IDs of all states in this state machine fragment.prefixStates(String prefix) Prefix the IDs of all states in this state machine fragment.Wrap all states in this state machine fragment up into a single state.toSingleState(SingleStateOptions options) Wrap all states in this state machine fragment up into a single state.Methods inherited from class software.constructs.Construct
getNode, isConstruct, toStringMethods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
StateMachineFragment
protected StateMachineFragment(software.amazon.jsii.JsiiObjectRef objRef) -
StateMachineFragment
protected StateMachineFragment(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
StateMachineFragment
@Stability(Stable) protected StateMachineFragment(@NotNull software.constructs.Construct scope, @NotNull String id) Creates a new construct node.- Parameters:
scope- The scope in which to define this construct. This parameter is required.id- The scoped construct ID. This parameter is required.
-
-
Method Details
-
next
Continue normal execution with the given state.- Parameters:
next- This parameter is required.
-
prefixStates
Prefix the IDs of all states in this state machine fragment.Use this to avoid multiple copies of the state machine all having the same state IDs.
- Parameters:
prefix- The prefix to add.
-
prefixStates
Prefix the IDs of all states in this state machine fragment.Use this to avoid multiple copies of the state machine all having the same state IDs.
-
toSingleState
Wrap all states in this state machine fragment up into a single state.This can be used to add retry or error handling onto this state machine fragment.
Be aware that this changes the result of the inner state machine to be an array with the result of the state machine in it. Adjust your paths accordingly. For example, change 'outputPath' to '$[0]'.
- Parameters:
options-
-
toSingleState
Wrap all states in this state machine fragment up into a single state.This can be used to add retry or error handling onto this state machine fragment.
Be aware that this changes the result of the inner state machine to be an array with the result of the state machine in it. Adjust your paths accordingly. For example, change 'outputPath' to '$[0]'.
-
getEndStates
The states to chain onto if this fragment is used.- Specified by:
getEndStatesin interfaceIChainable
-
getId
Descriptive identifier for this chainable.- Specified by:
getIdin interfaceIChainable
-
getStartState
The start state of this state machine fragment.- Specified by:
getStartStatein interfaceIChainable
-