在 AWS Step Function 中使用 Map 状态来迭代一组输入对象。分布式 Map 状态使用 Step Functions 数据库来跨多个实例分发和处理 Map 迭代。每个迭代是由执行器执行的,在执行器之间进行负载平衡。
在这种情况下,“Label”指的是标记 Map 状态中特定迭代的字符串。它用作 Map 任务的唯一标识符,并在 Map 迭代之间传递。
下面是 AWS 文档中 Map 状态包含“Label”的代码示例:
{
"Comment": "A description of the state machine",
"StartAt": "Map State Name",
"States": {
"Map State Name": {
"Type": "Map",
"MaxConcurrency": number,
"InputPath": "$",
"OutputPath": "$",
"Iterator": ,
"ItemsPath": ,
"Parameters": ,
"ResultPath": "$.MapName",
"Next": "Next State Name",
"End": true|false
},
"Next State Name": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "MyFunction",
"Payload": {
"Input.$": "$"
}
},
"ResultPath": "$.SomeResult",
"Retry": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"IntervalSeconds": 2,
"MaxAttempts": 3,
"BackoffRate": number
}
],
"Catch": [
{
"ErrorEquals": [
"States.TaskFailed"
],
"Next": "Alternate State Name"
}
],
"End": true|false
},
"Alternate State Name": {
"Type": "Task",
"Resource": "arn:aws:states:::lambda:invoke",
"Parameters": {
"FunctionName": "MyOtherFunction",
"Payload.$": "$.SomeErrorDetails"
},
"Next": "Next State Name",
"ResultPath": "$.SomeOtherResult",
}
}
}