I want to have a state machine, with a loop over an array. A loop is just a sequential map state (concurrency = 1). If one item of the array fails being processed, the map stops, and somehow I want to know which items were successful and which one failed.
This is this remembering of success/failures which I cannot manage to do.
- If I create an array variable in the outer scope before the map state, I am not able to update it during the map runs (The variable name was already defined in a parent scope)
- Every success can add an output to the map step, but failure cannot.
- If I do not use an actual failure, but try and remember the successes/failure with a boolean flag, I get the same issue as 1.
- Trying to use
$states.context.Map.Item.Name
anywhere inside the map fails (variable does not exist)
As an example, this is the simplified machine. The payload is hardcoded ([1, 2, 1]
), and the map only checks if an element is <2. If yes: success, if not: failure. As output (or in a variable, or...) I would like something like [{"Success":1}, {"Failure": 2}]
where the second 1 has not been processed. The actual structure of the output does not matter much.
{
"QueryLanguage": "JSONata",
"Comment": "A description of my state machine",
"StartAt": "Map",
"States": {
"Map": {
"Type": "Map",
"ItemProcessor": {
"ProcessorConfig": {
"Mode": "INLINE"
},
"StartAt": "Choice",
"States": {
"Choice": {
"Type": "Choice",
"Choices": [
{
"Next": "Store success",
"Condition": "{% $states.input < 2 %}",
"Output": {
"Success": "{% $states.input %}"
}
}
],
"Default": "Fail"
},
"Store success": {
"Type": "Pass",
"End": true
},
"Fail": {
"Type": "Fail"
}
}
},
"Next": "Pass",
"Catch": [
{
"ErrorEquals": [
"States.ALL"
],
"Next": "Pass"
}
],
"Items": [
1,
2,
1
],
"MaxConcurrency": 1,
"Output": {
"o": "{% $states.input %}"
}
},
"Pass": {
"Type": "Pass",
"End": true
}
}
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745102346a4611350.html
评论列表(0条)