-
Notifications
You must be signed in to change notification settings - Fork 2.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
Funqy Amazon Lambda should support more Amazon events #40396
Conversation
Thanks for your pull request! The title of your pull request does not follow our editorial rules. Could you have a look?
This message is automatically generated by a bot. |
I am not sure, but I think normally the prs get assigned to a person automatically. Does this mean nobody is responsible for Funqy anymore, and does this mean you drop the support for Funqy? Br, |
Neither assumption is correct, we simply missed this. @patriot1burke is responsible for Funqy |
@geoand thx for the extremly fast response. |
🙏 |
AWS supports cloud events now? |
This is really good. Let me dive in next week. |
Hi @patriot1burke,
Sounds great. Let me know what I messed up and can be improved.
Yes AWS supports CloudEvents. At least kind of. Via AWS EventBridge: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-api-destinations-cloudevents.html Br, |
Hi @patriot1burke, I do not really want to change the topic of this pr, but I noticed this log during development in CloudWatch: After checking I found this line of code: Line 59 in 93bc759
Does not this mean that the LambdaPollLoop is also executed in production in case a native build is used? Is this intended? For me this class looks like it should be used for testing (dev / test) purposes only. Am I missing something? |
@holomekc The poll loop runs when you deploy a quarkus lambda as a native executable. It will also run in dev and test mode along with a mock event server. |
@holomekc Oh, and yes, it is intended to work with native executable. Native executables fall under custom lambdas: https://docs.aws.amazon.com/lambda/latest/dg/runtimes-custom.html |
Hi @patriot1burke, thx for the information. I totally missed that. |
Where are we on this one? |
Hi @gsmet , I am still waiting for more feedback. Especially for the four things I mentioned in my initial post. |
It seems my review comments were in "pending"....not sure how to get them out of "pending" |
I wrote this comment weeks ago after looking at your test functions: If I'm making bad assumptions about your submition, let me know and I'll dive deeper. So...The WHOLE point of funqy is to be function agnostic. If you are adding support to pull in AWS event types into your application code, what is the point of using funqy? Just use AWS Lambda APIs instead. What I thought you were doing was allowing different AWS event types behind the scenes so @FunQ I thought you were adding support for different AWS message types that could unpack the AWS message and deserialize it to a application specific type. |
...da/common-runtime/src/main/java/io/quarkus/amazon/lambda/runtime/AbstractLambdaPollLoop.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Funq("sqs-function") | ||
public Uni<Void> sqsFunction(SQSEvent.SQSMessage msg) { |
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.
If I'm making bad assumptions about your submition, let me know and I'll dive deeper.
So...The WHOLE point of funqy is to be function agnostic. If you are adding support to pull in AWS event types into your application code, what is the point of using funqy? Just use AWS Lambda APIs instead.
What I thought you were doing was allowing different AWS event types behind the scenes so
@Funq
public void myFunc(MyType message) {
}
I thought you were adding support for different AWS message types that could unpack the AWS message and deserialize it to a application specific type.
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.
Yes it is exactly that. In this class I have different Funq methods. The "item-function" is the one you are looking for. When you then check SqsFunctionTest (https://github.com/quarkusio/quarkus/pull/40396/files#diff-b5a78b7cdaacb019453a4395d8a8af3644d689f4cdddc512ca5f550d7e9cca70) You can see that this test is only using the "item-function" for testing. So In this case the user only works with the message model, which is "Item" in this case and no cloud specific models are used.
The other methods exists to also test if the user wants to use the actual event models from the AWS SDK. This is then tested in SqsEventFunctionTest (https://github.com/quarkusio/quarkus/pull/40396/files#diff-316ae74a342b75733f0d16d2e40e8acffa8ad938cf431c789117cdb2e6c0d588) There you can see that the funq method is changed for the tests. If this is necessary to test I am not sure.
There is one exception though. The DynamoDB events. Due to its structure (newItem, oldItem) it is not really possible to deserialize it to an internal model. So I am not sure what to do there. But there is still the special treatment for the batching.
I hope this is understandable. If you need further info, please let me know.
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.
Some addition. I did it like this, because I saw the same handling in other funqy extensions regarding CloudEvents. It was allows to use the internal message model and it was allowed to use the CloudEvents model. But yeah there is a difference, because CloudEvents is not specific to a cloud provided, so maybe there it makes more sense. But I am not sure if this really hurts if it is possible to use the specific model as well.
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.
CloudEvents is a special case. The serverless team at red hat needed a function model for cloud events specification.
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.
Due to the removal of the content type in the poll loop I needed to adjust the tests, while I did that I added a short description in jdoc why a test exists and what it covers. Maybe it also provides some insights why I implemented it like it is. If not please let me know if I can help somehow.
I swear I clicked "Submit review" weeks ago....sorry for holding this up. |
Hi @patriot1burke , thx for the feedback and no worries. I was on vacation and on sick leave anyway so no holding up here. One comment is doubled. I added my feedback to the inline comment. I could need some feedback regarding the EventDeserializer though. See: https://github.com/quarkusio/quarkus/pull/40396/files#diff-7c7bb52403a3ef27cd1c40c3e4a3959781175e3d05033a6b4d66663894b15996 |
Hi @patriot1burke |
I am working on some refactoring, so that it is closer to the existing structure. I am close, but still need a little bit of time. I will try to do that asap |
Hi @patriot1burke, I refactored some parts. It should be less invasive now, and hopefully easier to understand. It would be awesome if you can take a look. The logic did not change though, except for Kinesis, where I had a bug to fix. |
Great work! Honestly, really great work. Any reason why advanced mode wouldn't be on by default? Is this a performance issue? If so, I'd say turn it on by default until somebody has a problem with performance of vanilla Funqy. |
Thx for the kind words. I hope you do not hate me now, because I realized I forgot to push :( I am so sorry. Not sure what happened. To make it easier. I did not change the deserialization much and also not the event handling. I just moved most logic to the AwsEventInputReader, which is implementing the LambdaInputReader interface, which seems to be the interface to use here. This results in less changes in the FunqyLambdaBindingRecorder. The AwsEventInputReader uses the ObjectMapper to deserialize the event and to look into the json structure to determine the actual type. If the type is found it continues deserialization to this specific event. Then the message is extracted from the event (EventHandler) and the already existing reader and writer from the "old" approach is used to deserialize to the model of the funqy method. Nothing else really changed regarding the logic. Also the batching stays the same. I did the changes mainly to reduce the complexity in the FunqyLambdaBindingRecorder Regarding performance. Not 100% sure, but I do not think so. With Jackson I read the json first to figure out the event as described above. So this could in theory influence performance. Should not be much, because it navigates through maps for certain indicators. So yes in theory I could remove the config. I will think about that. Br and sorry once again, Edit: I rebased the branch to be up-to-date. I can squash the commits if you think my refactoring was ok. |
Maybe you can help me here: https://github.com/quarkusio/quarkus/pull/40396/files#diff-025bb7ab865d989d9f60525c861771a6805efa192f5d22a60ace6df5f92769c0 I do not understand how this stuff works. I am afraid of breaking the native builds, so that it does not find the necessary models during Jackson deserialization. I could not figure out how I could write a test for native mode. Maybe I also need to add the cloud events model? |
This comment has been minimized.
This comment has been minimized.
Best approach is to investigate the deployment to only add the classes you need as reflective classes. Can you even know how Funqy will be deployed though at build time? Also, any reason you can't turn on the advanced features by default? |
I will check. I think I can also build one of our native lambdas locally, with this quarkus version, and check how it behaves. I will try to do that asap. |
f00342b
to
8099e82
Compare
Hi @patriot1burke Besides that only debug logging added and minor log message changes. Besides that I think the pr is complete now. Edit: Not sure about missing documentation though. |
This comment has been minimized.
This comment has been minimized.
I will take a look. |
e1ea745
to
0bc0a66
Compare
Hi @patriot1burke
I hope I covered it now. If something is still not ok, please let me know |
This comment has been minimized.
This comment has been minimized.
Hi @patriot1burke, |
This comment has been minimized.
This comment has been minimized.
- Support for SQS, SNS, DynamoDB and Kinesis, with focus on the batching feature of AWS. Furthermore, add support for CloudEvents. - Add tests for funqy amazon lambda - Refactor, so that the implementation is less invasive. Using the JacksonInputReader and JacksonOutputWriter for the advanced event handling. - Fix issue in Kinesis event handling - Add logging - Advanced event handling is the new default
Status for workflow
|
Nice work. Thanks for sticking with this so long! |
Nice. Thx for being so patient. |
Why this feature. We like the Funqy extension. Sadly it makes the usage in AWS a bit difficult at the moment, because although Funqy seems to be cloud agnostic this is not really the case when Event driven sources are used as trigger for a lambda function. E.g. SQS. When using SQS it was necessary to use the SQS model in the funq method, which reduces the benefit of a cloud agnostic solution. Furthermore, it prevents the usage of features of AWS batching.
Requirements
To solve that I thought about the following requirements:
So I checked the following documentation of AWS:
AWS Lambda: https://docs.aws.amazon.com/lambda/latest/dg/lambda-services.html
AWS EventBridge Pipes: https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-pipes-event-source.html
I checked AWS EventBridge Pipes, because this allows to use CloudEvents in AWS. E.g.:
With an input transformer similar to this:
So what did I do
What is tricky and I could need feedback for
Last words
I know this PR looks huge. There are a lot of json test files though. I would love if you could take a look and tell me what you think. Help would be appreciated.