Skip to content

Commit eb0a492

Browse files
authored
fixes #143 Correct the logic for max retries in the handler and config comment (#144)
1 parent 63c3c60 commit eb0a492

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

lambda-invoker/src/main/java/com/networknt/aws/lambda/LambdaFunctionHandler.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,12 @@ public LambdaFunctionHandler() {
6262
if(config.getMaxRetries() > 0) {
6363
overrideConfig = overrideConfig.toBuilder()
6464
.retryStrategy(DefaultRetryStrategy.standardStrategyBuilder()
65-
.maxAttempts(config.getMaxRetries())
66-
.build())
65+
.maxAttempts(config.getMaxRetries() + 1) // +1 because the first attempt is not counted as a retry
66+
.build())
67+
.build();
68+
} else {
69+
overrideConfig = overrideConfig.toBuilder()
70+
.retryStrategy(DefaultRetryStrategy.doNotRetry())
6771
.build();
6872
}
6973

lambda-invoker/src/main/resources/config/lambda-invoker.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ endpointOverride: ${lambda-invoker.endpointOverride:}
77
apiCallTimeout: ${lambda-invoker.apiCallTimeout:60000}
88
# Api call attempt timeout in milliseconds. This sets the amount of time for each individual attempt.
99
apiCallAttemptTimeout: ${lambda-invoker.apiCallAttemptTimeout:20000}
10-
# The maximum number of retries for the Lambda function invocation. Default is 3. Set to 0 to disable retries.
11-
maxRetries: ${lambda-invoker.maxRetries:3}
10+
# The maximum number of retries for the Lambda function invocation. Default is 2, which equals to 3 max attempts.
11+
# Set to 0 to disable retries so that the Lambda function is invoked only once.
12+
maxRetries: ${lambda-invoker.maxRetries:2}
1213
# The maximum number of concurrent requests that can be made to Lambda. Default is 50.
1314
maxConcurrency: ${lambda-invoker.maxConcurrency:50}
1415
# The maximum number of pending acquires allowed. Default is 10000.

0 commit comments

Comments
 (0)