Class Parallel
Define a Parallel state in the state machine.
Inherited Members
Namespace: Amazon.CDK.AWS.StepFunctions
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class Parallel : State, IChainable, INextable
Syntax (vb)
Public Class Parallel
Inherits State
Implements IChainable, INextable
Remarks
A Parallel state can be used to run one or more state machines at the same time.
The Result of a Parallel state is an array of the results of its substatemachines.
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
Parallel(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
Parallel(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Parallel(Construct, String, IParallelProps) |
Properties
EndStates | Continuable states of this Chainable. |
Methods
AddCatch(IChainable, ICatchProps) | Add a recovery handler for this state. |
AddRetry(IRetryProps) | Add retry configuration for this state. |
BindToGraph(StateGraph) | Overwrites State.bindToGraph. Adds branches to the Parallel state here so that any necessary prefixes are appended first. |
Branch(IChainable[]) | Define one or more branches to run in parallel. |
Next(IChainable) | Continue normal execution with the given state. |
ToStateJson() | Return the Amazon States Language object for this state. |
ValidateState() | Validate this state. |
Constructors
Parallel(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected Parallel(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
Parallel(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected Parallel(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Parallel(Construct, String, IParallelProps)
public Parallel(Construct scope, string id, IParallelProps props = null)
Parameters
- scope Constructs.Construct
- id System.String
Descriptive identifier for this chainable.
- props IParallelProps
Properties
EndStates
Continuable states of this Chainable.
public override INextable[] EndStates { get; }
Property Value
Overrides
Methods
AddCatch(IChainable, ICatchProps)
Add a recovery handler for this state.
public virtual Parallel AddCatch(IChainable handler, ICatchProps props = null)
Parameters
- handler IChainable
- props ICatchProps
Returns
Remarks
When a particular error occurs, execution will continue at the error handler instead of failing the state machine execution.
AddRetry(IRetryProps)
Add retry configuration for this state.
public virtual Parallel AddRetry(IRetryProps props = null)
Parameters
- props IRetryProps
Returns
Remarks
This controls if and how the execution will be retried if a particular error occurs.
BindToGraph(StateGraph)
Overwrites State.bindToGraph. Adds branches to the Parallel state here so that any necessary prefixes are appended first.
public override void BindToGraph(StateGraph graph)
Parameters
- graph StateGraph
Overrides
Branch(IChainable[])
Define one or more branches to run in parallel.
public virtual Parallel Branch(params IChainable[] branches)
Parameters
- branches IChainable[]
Returns
Next(IChainable)
Continue normal execution with the given state.
public virtual Chain Next(IChainable next)
Parameters
- next IChainable
Returns
ToStateJson()
Return the Amazon States Language object for this state.
public override JObject ToStateJson()
Returns
Newtonsoft.Json.Linq.JObject
Overrides
ValidateState()
Validate this state.
protected override string[] ValidateState()
Returns
System.String[]