Skip to content

Make Events derive from a common abstract type #59

Closed

Description

@jaferrando

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.

Activity

  1. jblacker commented on Feb 26, 2019

    @jblacker

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

  2. jainishshah17 commented on Aug 15, 2019

    @jainishshah17

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

  3. simon1389 commented on Sep 23, 2021

    @simon1389

    any updates on this?

  4. msailes commented on Sep 24, 2021

    @msailes
    Contributor

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

  5. smirnoal commented on May 13, 2022

    @smirnoal
    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!

  6. added a commit that references this issue on Jun 28, 2024
  7. smirnoal commented on Sep 3, 2024

    @smirnoal
    Contributor

    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.

  8. added a commit that references this issue on Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions