Class StateMachineFragment
Base class for reusable state machine fragments.
Inheritance
Implements
Namespace: Amazon.CDK.AWS.StepFunctions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public abstract class StateMachineFragment : Construct, IChainable
Syntax (vb)
Public MustInherit Class StateMachineFragment
Inherits Construct
Implements IChainable
Remarks
ExampleMetadata: nofixture infused
Examples
using Amazon.CDK;
using Constructs;
using Amazon.CDK.AWS.StepFunctions;
class MyJobProps
{
public string JobFlavor { get; set; }
}
class MyJob : StateMachineFragment
{
public State StartState { get; }
public INextable[] EndStates { get; }
public MyJob(Construct parent, string id, MyJobProps props) : base(parent, id)
{
var 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"));
// ...
StartState = choice;
EndStates = choice.Afterwards().EndStates;
}
}
class MyStack : Stack
{
public MyStack(Construct scope, string id) : base(scope, id)
{
// Do 3 different variants of MyJob in parallel
var 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());
new StateMachine(this, "MyStateMachine", new StateMachineProps {
DefinitionBody = DefinitionBody.FromChainable(parallel)
});
}
}
Synopsis
Constructors
StateMachineFragment(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
StateMachineFragment(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
StateMachineFragment(Construct, String) | Creates a new construct node. |
Properties
EndStates | The states to chain onto if this fragment is used. |
Id | Descriptive identifier for this chainable. |
StartState | The start state of this state machine fragment. |
Methods
Next(IChainable) | Continue normal execution with the given state. |
PrefixStates(String) | Prefix the IDs of all states in this state machine fragment. |
ToSingleState(ISingleStateOptions) | Wrap all states in this state machine fragment up into a single state. |
Constructors
StateMachineFragment(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected StateMachineFragment(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
StateMachineFragment(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected StateMachineFragment(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
StateMachineFragment(Construct, String)
Creates a new construct node.
protected StateMachineFragment(Construct scope, string id)
Parameters
- scope Constructs.Construct
The scope in which to define this construct.
- id System.String
The scoped construct ID.
Properties
EndStates
The states to chain onto if this fragment is used.
public abstract INextable[] EndStates { get; }
Property Value
Id
Descriptive identifier for this chainable.
public virtual string Id { get; }
Property Value
System.String
StartState
The start state of this state machine fragment.
public abstract State StartState { get; }
Property Value
Methods
Next(IChainable)
Continue normal execution with the given state.
public virtual Chain Next(IChainable next)
Parameters
- next IChainable
Returns
PrefixStates(String)
Prefix the IDs of all states in this state machine fragment.
public virtual StateMachineFragment PrefixStates(string prefix = null)
Parameters
- prefix System.String
The prefix to add.
Returns
Remarks
Use this to avoid multiple copies of the state machine all having the same state IDs.
ToSingleState(ISingleStateOptions)
Wrap all states in this state machine fragment up into a single state.
public virtual Parallel ToSingleState(ISingleStateOptions options = null)
Parameters
- options ISingleStateOptions
Returns
Remarks
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]'.