Skip to content

Make Events derive from a common abstract type #59

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

Closed
jaferrando opened this issue Sep 25, 2018 · 6 comments
Closed

Make Events derive from a common abstract type #59

jaferrando opened this issue Sep 25, 2018 · 6 comments

Comments

@jaferrando
Copy link

jaferrando commented Sep 25, 2018

Use case: Create a lambda function that handles different event types

The handler class has to implement the RequestHandler interface with <T,String>, being T one of the event types. As those do not share a common ancestory type, we need to implement the handling of each event type as a separa te class, and hence a separate Lambda. Having a common ancestor type would allow to implement RequestHandler<LambdaEventAbstractType,String> and determine in the handler function the type of event by inspecting its class with event.getClass().
This would also be a more Object oriented design, with a group of closely related types having a common ancestor.
We can now do something similar by implementing RequestHandler<Object,String> but it is poorer design and too loose in terms of type control.

@jblacker
Copy link

This would be very helpful for creating base classes and shared logic between different lambda functions or multiple triggers to the same function.

@jainishshah17
Copy link

I am also looking for this feature. I want to trigger my lambda function with SQSEvent/CloudWatchLogs Event.

@simon1389
Copy link

any updates on this?

@msailes
Copy link
Collaborator

msailes commented Sep 24, 2021

No, update. This may be considered in the future, but not at the moment.

@smirnoal
Copy link
Contributor

which interface do you think would be useful to introduce? Also wanted to learn more about what would differentiate LambdaEventAbstractType from Object, usecases would be helpful. Thanks!

maxday added a commit that referenced this issue Jun 28, 2024
@smirnoal
Copy link
Contributor

smirnoal commented Sep 3, 2024

resolving this issue as not planned. I would not recommend the proposed pattern with LambdaEventAbstractType and making reflection api calls to determine the actual type during runtime, but rather use compile-time capabilities to detect possible errors earlier in the process.

@smirnoal smirnoal closed this as completed Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants