RequestStreamHandler functionality added to Amazon Lambda #7866
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary:
Amazon Lambda extension currently only supports the interface RequestHandler.
Enhance the extension, to enable the use of the interface RequestStreamHandler, so that both AWS Lambda interfaces are supported.
#6707 requests this functionality.
The RequestStreamHandler can co-exist in a project with RequestHandler, and the active function toggled via the property quarkus.lambda.handler, as normal. The requestHandler signature for the former has 3 params, the latter 2.
Validated as working for NativeImage, via SAM and AWS.
Specifics:
Deployment:
AmazonLambdaBuildItem adds a flag to indicate whether the scanned requestHandler is of type RequestStreamHandler, since it was the only way I could determine this (tried lots of options not to modify this BuildItem class).
public AmazonLambdaBuildItem(String handlerClass, String name, boolean streamHandler) {
Various changes to AmazonLambdaProcessesor to recognise and process the RequestStreamHandler::requestHandler implementation.
Runtime:
AmazonLambdaRecorder has similar changes to accept the co-existance of the RequestStreamHandler::requestHandler implementation.
Only one lambda handler can be active, per the existing validation in chooseHandlerClass, thus the code is checking which one is present to determine how to branch.
Added a compatible integration test for the AmazonClient.invoke in the test-framework for Amazon Lambda. I used this to test both.
Archetype:
Added a StreamHandler to the archetype, to demonstrate you can have both in your project, and that you must use the @nAmed annotation along with the application.properties to select the active lambda function, per existing functionality.
In addition, I added test functionality to include the integration test for Amazon Lambda into the archetype, as that is an easy way for people to test their functions, and wasn't previously in the archetype. For JVM, there is no need to use SAM when you have the integration test available (see issues with SAM for JVM #6701) which I continue to experience.
Tested by:
(repeated toggling the application.property to swap handler type quarkus.lambda.handler)
/cc @patriot1burke
/cc @evanchooly
/cc @bnusunny