-
Notifications
You must be signed in to change notification settings - Fork 5.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#4750 Java invoke local support for handlers that implement RequestStreamHandler #5954
#4750 Java invoke local support for handlers that implement RequestStreamHandler #5954
Conversation
…me.RequestStreamHandler compatible handlers during "sls invoke local"
"CloudFront-Is-SmartTV-Viewer": "false", | ||
"CloudFront-Is-Tablet-Viewer": "false", | ||
"CloudFront-Viewer-Country": "KR", | ||
"Host": "rr4lbbmtfb.execute-api.us-east-1.amazonaws.com", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old test dev APP id -- no longer valid.
"Postman-Token": "60d4d786-60bf-4ba5-bcde-5a00ac688041", | ||
"User-Agent": "PostmanRuntime/7.3.0", | ||
"Via": "1.1 17b1095550a8ffe13061114dbfceeb81.cloudfront.net (CloudFront)", | ||
"X-Amz-Cf-Id": "QK3FgYHC89HWK03RsV7L8lJv34WzlFDyHmS0pbbCYtz9WyUCiw7JCQ==", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Old test dev CF id -- no longer valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Thanks for working on this @XaeroDegreaz 👍
This looks good from a code perspective. Unfortunately I wasn't able to test this on my machine (both bare metal and in Docker) since building the bridge takes forever and it hangs there. I tested invoke local
against master
and I see the same issue, so it might be something with my setup.
@dschep @eahefnawy could you test this? After that we should be able to merge this soon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating this PR @XaeroDegreaz 👍
Looks like we're almost there. Just a minor permissions error with the invoke local
bridge:
[nix-shell:~/code/serverless/tmp/java-maven]$ ../../bin/serverless invoke local -f hello
Serverless: In order to get human-readable output, please implement "toString()" method of your "ApiGatewayResponse" object.
Error: Unable to access jarfile ~/code/serverless/lib/plugins/aws/invokeLocal/java/target/invoke-bridge-1.0.1.jar
Let us know if you need any help here!
Hm, did you put the I'm not entirely sure how one would test it other than that. I just packaged the jar manually, dumped it in the plugin directory, updated the Once I saw that worked, I updated the How are you testing? If you'd prefer, I can just revert the commit incrementing the version. It just seemed like the appropriate thing to do at the moment, but if it's somehow introduced some new complication in the file permissions (not sure where all of that is set up), then I'm fine with a revert. |
Thanks for the reply @XaeroDegreaz 👍 I started with a regular So what I did was:
This works on |
Ahh, I see! Ok, so after I'm assuming that you guys have some build process that does this for the real distribution that people get, i.e. performs the Maven build then puts the artifact where it needs to go for dist, however in this instance, you're simply checking out the repository as-is, building the JAR, and not doing anything with it :D Hope it helps! |
Thanks for the follow-up @XaeroDegreaz 👍 I just tested it again and it works. The reason why it failed on my end was that I had the old bridge built (from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What did you implement:
Closes #4750
How did you implement it:
I performed some checks inside the invoke method to support
RequestStreamHandler
compatible handlers. The checks include testing whether or not the first parameter was anInputStream
type, and also a similar check during the reflected method invocation.How can we verify it:
Unit tests are included that verify that
RequestStreamHandler
methods can receive input, and write to anOutputStream
. You can verify it by running the tests from your IDE, or simply runmvn clean test
in the root of the plugin's directory.You can also run
mvn clean package
from the plugin's directory; it will run the tests, and output the plugin JAR totarget/invoke-bridge-1.0.jar
. You can take this JAR file and put it in your globalnode_modules
directory that housesserverless
. For instance on my machine that location is/usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/java/target
. Be sure to back up the originalserverless
JAR, just in case ;)After replacing your JAR, you can run
sls invoke local
with your function (one that handlesRequestStreamHandler
), and provide a path to some target data file to verify functionality.Todos:
Is this ready for review?: YES
Is it a breaking change?: NO