-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When batching, optimize the number of items to send against the maxim…
…um allowed by AWS Lambda. Whether batching or not, handle cases where the payload size is beyond the maximum allowed by AWS Lambda: Meaningful log message when max exceeded; Failure behavior should be configurable: stop or drop and continue.
- Loading branch information
1 parent
2ef25c5
commit 585d2c1
Showing
7 changed files
with
119 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/com/nordstrom/kafka/connect/lambda/InvocationFailure.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package com.nordstrom.kafka.connect.lambda; | ||
|
||
public enum InvocationFailure { | ||
STOP, DROP | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/test/java/com/nordstrom/kafka/connect/lambda/AwsLambdaUtilTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.nordstrom.kafka.connect.lambda; | ||
|
||
import com.amazonaws.services.lambda.model.InvocationType; | ||
import com.amazonaws.services.lambda.model.RequestTooLargeException; | ||
import org.junit.Test; | ||
|
||
import java.time.Instant; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
public class AwsLambdaUtilTest { | ||
|
||
@Test(expected = RequestTooLargeException.class) | ||
public void testCheckPayloadSizeForInvocationTypeWithInvocationFailureModeStopThrowsException() { | ||
|
||
final Configuration testConfiguration = new Configuration("test-profile", "testhost", 123, "test-region", InvocationFailure.STOP); | ||
final AwsLambdaUtil testUtil = new AwsLambdaUtil(testConfiguration); | ||
|
||
testUtil.checkPayloadSizeForInvocationType("testpayload".getBytes(), InvocationType.RequestResponse, Instant.now(), new RequestTooLargeException("Request payload is too large!")); | ||
} | ||
|
||
@Test | ||
public void testCheckPayloadSizeForInvocationTypeWithInvocationFailureModeDropContinues() { | ||
|
||
AwsLambdaUtil.InvocationResponse testResp = null; | ||
RequestTooLargeException ex = null; | ||
|
||
final Configuration testConfiguration = new Configuration("test-profile", "testhost", 123, "test-region", InvocationFailure.DROP); | ||
final AwsLambdaUtil testUtil = new AwsLambdaUtil(testConfiguration); | ||
|
||
try { | ||
testResp = testUtil.checkPayloadSizeForInvocationType("testpayload".getBytes(), InvocationType.RequestResponse, Instant.now(), new RequestTooLargeException("Request payload is too large!")); | ||
} catch (RequestTooLargeException e) { | ||
ex = e; | ||
} | ||
|
||
assertNull(ex); | ||
assertNotNull(testResp); | ||
assertEquals(400, testResp.getStatusCode().intValue()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters