DistributedMap
- class aws_cdk.aws_stepfunctions.DistributedMap(scope, id, *, item_batcher=None, item_reader=None, label=None, map_execution_type=None, result_writer=None, tolerated_failure_count=None, tolerated_failure_count_path=None, tolerated_failure_percentage=None, tolerated_failure_percentage_path=None, comment=None, input_path=None, item_selector=None, items_path=None, max_concurrency=None, max_concurrency_path=None, output_path=None, result_path=None, result_selector=None, state_name=None)
Bases:
MapBase
Define a Distributed Mode Map state in the state machine.
A
Map
state can be used to run a set of steps for each element of an input array. A Map state will execute the same steps for multiple entries of an array in the state input.While the Parallel state executes multiple branches of steps using the same input, a Map state will execute the same steps for multiple entries of an array in the state input.
A
Map
state inDistributed
mode will execute a child workflow for each iteration of the Map state. This serves to increase concurrency and allows for larger workloads to be run in a single state machine.- See:
https://docs.aws.amazon.com/step-functions/latest/dg/concepts-asl-use-map-state-distributed.html
- ExampleMetadata:
infused
Example:
distributed_map = sfn.DistributedMap(self, "Distributed Map State", max_concurrency=1, items_path=sfn.JsonPath.string_at("$.inputForMap") ) distributed_map.item_processor(sfn.Pass(self, "Pass State"))
- Parameters:
scope (
Construct
) –id (
str
) – Descriptive identifier for this chainable.item_batcher (
Optional
[ItemBatcher
]) – Specifies to process a group of items in a single child workflow execution. Default: - No itemBatcheritem_reader (
Optional
[IItemReader
]) – ItemReader. Configuration for where to read items dataset in S3 to iterate Default: - No itemReaderlabel (
Optional
[str
]) – Label. Unique name for the Distributed Map state added to each Map Run Default: - No labelmap_execution_type (
Optional
[StateMachineType
]) – MapExecutionType. The execution type of the distributed map state This property overwrites ProcessorConfig.executionType Default: StateMachineType.STANDARDresult_writer (
Optional
[ResultWriter
]) – Configuration for S3 location in which to save Map Run results. Default: - No resultWritertolerated_failure_count (
Union
[int
,float
,None
]) – ToleratedFailureCount. Number of failed items to tolerate in a Map Run, as static number Default: - No toleratedFailureCounttolerated_failure_count_path (
Optional
[str
]) – ToleratedFailureCountPath. Number of failed items to tolerate in a Map Run, as JsonPath Default: - No toleratedFailureCountPathtolerated_failure_percentage (
Union
[int
,float
,None
]) – ToleratedFailurePercentage. Percentage of failed items to tolerate in a Map Run, as static number Default: - No toleratedFailurePercentagetolerated_failure_percentage_path (
Optional
[str
]) – ToleratedFailurePercentagePath. Percentage of failed items to tolerate in a Map Run, as JsonPath Default: - No toleratedFailurePercentagePathcomment (
Optional
[str
]) – An optional description for this state. Default: No commentinput_path (
Optional
[str
]) – JSONPath expression to select part of the state to be the input to this state. May also be the special value JsonPath.DISCARD, which will cause the effective input to be the empty object {}. Default: $item_selector (
Optional
[Mapping
[str
,Any
]]) – The JSON that you want to override your default iteration input (mutually exclusive withparameters
). Default: $items_path (
Optional
[str
]) – JSONPath expression to select the array to iterate over. Default: $max_concurrency (
Union
[int
,float
,None
]) – MaxConcurrency. An upper bound on the number of iterations you want running at once. Default: - full concurrencymax_concurrency_path (
Optional
[str
]) – MaxConcurrencyPath. A JsonPath that specifies the maximum concurrency dynamically from the state input. Default: - full concurrencyoutput_path (
Optional
[str
]) – JSONPath expression to select part of the state to be the output to this state. May also be the special value JsonPath.DISCARD, which will cause the effective output to be the empty object {}. Default: $result_path (
Optional
[str
]) – JSONPath expression to indicate where to inject the state’s output. May also be the special value JsonPath.DISCARD, which will cause the state’s input to become its output. Default: $result_selector (
Optional
[Mapping
[str
,Any
]]) – The JSON that will replace the state’s raw result and become the effective result before ResultPath is applied. You can use ResultSelector to create a payload with values that are static or selected from the state’s raw result. Default: - Nonestate_name (
Optional
[str
]) – Optional name for this state. Default: - The construct ID will be used as state name
Methods
- add_catch(handler, *, errors=None, result_path=None)
Add a recovery handler for this state.
When a particular error occurs, execution will continue at the error handler instead of failing the state machine execution.
- Parameters:
handler (
IChainable
) –errors (
Optional
[Sequence
[str
]]) – Errors to recover from by going to the given state. A list of error strings to retry, which can be either predefined errors (for example Errors.NoChoiceMatched) or a self-defined error. Default: All errorsresult_path (
Optional
[str
]) – JSONPath expression to indicate where to inject the error data. May also be the special value JsonPath.DISCARD, which will cause the error data to be discarded. Default: $
- Return type:
- add_prefix(x)
Add a prefix to the stateId of this state.
- Parameters:
x (
str
) –- Return type:
None
- add_retry(*, backoff_rate=None, errors=None, interval=None, jitter_strategy=None, max_attempts=None, max_delay=None)
Add retry configuration for this state.
This controls if and how the execution will be retried if a particular error occurs.
- Parameters:
backoff_rate (
Union
[int
,float
,None
]) – Multiplication for how much longer the wait interval gets on every retry. Default: 2errors (
Optional
[Sequence
[str
]]) – Errors to retry. A list of error strings to retry, which can be either predefined errors (for example Errors.NoChoiceMatched) or a self-defined error. Default: All errorsinterval (
Optional
[Duration
]) – How many seconds to wait initially before retrying. Default: Duration.seconds(1)jitter_strategy (
Optional
[JitterType
]) – Introduces a randomization over the retry interval. Default: - No jitter strategymax_attempts (
Union
[int
,float
,None
]) – How many times to retry this particular error. May be 0 to disable retry for specific errors (in case you have a catch-all retry policy). Default: 3max_delay (
Optional
[Duration
]) – Maximum limit on retry interval growth during exponential backoff. Default: - No max delay
- Return type:
- bind_to_graph(graph)
Register this state as part of the given graph.
Don’t call this. It will be called automatically when you work with states normally.
- Parameters:
graph (
StateGraph
) –- Return type:
None
- item_processor(processor, *, execution_type=None, mode=None)
Define item processor in a Distributed Map.
A Distributed Map must have a non-empty item processor
- Parameters:
processor (
IChainable
) –execution_type (
Optional
[ProcessorType
]) – Specifies the execution type for the Map workflow. If you use theMap
class, you must provide this field if you specifiedDISTRIBUTED
for themode
sub-field. If you use theDistributedMap
class, this property is ignored. Use themapExecutionType
in theDistributedMap
class instead. Default: - no execution typemode (
Optional
[ProcessorMode
]) – Specifies the execution mode for the Map workflow. Default: - ProcessorMode.INLINE if using theMap
class, ProcessorMode.DISTRIBUTED if using theDistributedMap
class
- Return type:
- next(next)
Continue normal execution with the given state.
- Parameters:
next (
IChainable
) –- Return type:
- to_state_json()
Return the Amazon States Language object for this state.
- Return type:
Mapping
[Any
,Any
]
- to_string()
Returns a string representation of this construct.
- Return type:
str
Attributes
- end_states
Continuable states of this Chainable.
- id
Descriptive identifier for this chainable.
- node
The tree node.
- start_state
First state of this Chainable.
- state_id
Tokenized string that evaluates to the state’s ID.
Static Methods
- classmethod filter_nextables(states)
Return only the states that allow chaining from an array of states.
- classmethod find_reachable_end_states(start, *, include_error_handlers=None)
Find the set of end states states reachable through transitions from the given start state.
- classmethod find_reachable_states(start, *, include_error_handlers=None)
Find the set of states reachable through transitions from the given start state.
This does not retrieve states from within sub-graphs, such as states within a Parallel state’s branch.
- classmethod is_construct(x)
Checks if
x
is a construct.Use this method instead of
instanceof
to properly detectConstruct
instances, even when the construct library is symlinked.Explanation: in JavaScript, multiple copies of the
constructs
library on disk are seen as independent, completely different libraries. As a consequence, the classConstruct
in each copy of theconstructs
library is seen as a different class, and an instance of one class will not test asinstanceof
the other class.npm install
will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of theconstructs
library can be accidentally installed, andinstanceof
will behave unpredictably. It is safest to avoid usinginstanceof
, and using this type-testing method instead.- Parameters:
x (
Any
) – Any object.- Return type:
bool
- Returns:
true if
x
is an object created from a class which extendsConstruct
.
- classmethod is_distributed_map(x)
Return whether the given object is a DistributedMap.
- Parameters:
x (
Any
) –- Return type:
bool
- classmethod prefix_states(root, prefix)
Add a prefix to the stateId of all States found in a construct tree.
- Parameters:
root (
IConstruct
) –prefix (
str
) –
- Return type:
None