mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(lambda): retain event source qualifiers at invocation (#6288)
Signed-off-by: Andre Kurait <akurait@amazon.com>
This commit is contained in:
1 parent
2ae6d16936
commit
504e0dfde7
7 files changed
+29
-18
No files matched your search
+4
-1
@@ -350,7 +350,10 @@ public class DynamoDbStreamsEventSourcePoller implements Resettable {
|
||||
String eventJson = buildDynamoDbEvent(matched, esm);
|
||||
InvokeResult invokeResult;
|
||||
try {
|
||||
invokeResult = executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse);
|
||||
String qualifier = LambdaTargetResolver.mappingQualifier(esm);
|
||||
invokeResult = qualifier == null
|
||||
? executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse)
|
||||
: executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse, 0, qualifier);
|
||||
} catch (AwsException e) {
|
||||
if ("TooManyRequestsException".equals(e.getErrorCode())) {
|
||||
LOG.infov("DynamoDB Streams ESM {0}: function {1} throttled, shard iterator not advanced",
|
||||
|
||||
+4
-1
@@ -173,7 +173,10 @@ public class KinesisEventSourcePoller implements Resettable {
|
||||
String eventJson = buildKinesisEvent(matched, esm, shard.getShardId());
|
||||
InvokeResult invokeResult;
|
||||
try {
|
||||
invokeResult = executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse);
|
||||
String qualifier = LambdaTargetResolver.mappingQualifier(esm);
|
||||
invokeResult = qualifier == null
|
||||
? executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse)
|
||||
: executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse, 0, qualifier);
|
||||
} catch (AwsException e) {
|
||||
if ("TooManyRequestsException".equals(e.getErrorCode())) {
|
||||
LOG.infov("Kinesis ESM {0}: function {1} throttled, shard iterator not advanced",
|
||||
|
||||
@@ -52,8 +52,7 @@ public class LambdaTargetResolver {
|
||||
|
||||
/** The function a mapping invokes, or empty when it or its version or alias is gone. */
|
||||
public Optional<LambdaFunction> resolveMappingTarget(EventSourceMapping esm) {
|
||||
String qualifier = esm.getFunctionArn() == null
|
||||
? null : LambdaArnUtils.resolve(esm.getFunctionArn()).qualifier();
|
||||
String qualifier = mappingQualifier(esm);
|
||||
try {
|
||||
return Optional.of(resolveInvokeTargetForAccount(
|
||||
esm.getAccountId(), esm.getRegion(), esm.getFunctionName(), qualifier));
|
||||
@@ -65,6 +64,10 @@ public class LambdaTargetResolver {
|
||||
}
|
||||
}
|
||||
|
||||
static String mappingQualifier(EventSourceMapping esm) {
|
||||
return esm.getFunctionArn() == null ? null : LambdaArnUtils.resolve(esm.getFunctionArn()).qualifier();
|
||||
}
|
||||
|
||||
private LambdaFunction resolveTarget(String region, String name, String qualifier,
|
||||
Function<LambdaAlias, String> aliasVersion) {
|
||||
if (qualifier == null || qualifier.equals("$LATEST")) {
|
||||
|
||||
@@ -266,8 +266,10 @@ public class SqsEventSourcePoller implements Resettable {
|
||||
LOG.infov("ESM {0}: invoking function {1}", esm.getUuid(), fn.getFunctionName());
|
||||
InvokeResult result;
|
||||
try {
|
||||
result = executorService.invoke(
|
||||
fn, eventJson.getBytes(), InvocationType.RequestResponse);
|
||||
String qualifier = LambdaTargetResolver.mappingQualifier(esm);
|
||||
result = qualifier == null
|
||||
? executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse)
|
||||
: executorService.invoke(fn, eventJson.getBytes(), InvocationType.RequestResponse, 0, qualifier);
|
||||
} catch (AwsException e) {
|
||||
if ("TooManyRequestsException".equals(e.getErrorCode())) {
|
||||
LOG.infov("ESM {0}: function {1} throttled, messages will return to queue after visibility timeout",
|
||||
|
||||
Reference in new issue
Block a user