-
Notifications
You must be signed in to change notification settings - Fork 406
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
RFC: Create an official utility event_handler
for lightweight event handlers
#356
Comments
Early stages as this need more details in the Proposal like what does UX look - Questions I have in my mind right now:
As this will be a core utility, bringing in Java and Typescript folks - @saragerion @pankajagrawal16 @alan-churley @msailes @mndeveci --- Do you agree with this direction? This would mean having implemented in Java and TS too as it'd be a core feature I'll be happy to edit the RFC and add some more details into it, as it's late here in EMEA :) |
This is a great idea! But I agree with @heitorlessa. Before signing off on it, @michaelbrewer are you able to add more info in this issue detailing:
|
I think it should be ported to other languages, and should be easier for ones that can already support decorators or aspect orientated programming. Benefit for the developer is they can implement a single function to handle multiple request types without doing many if/elses or having to understand how to convert an api gateway proxy event into something more like a http request |
Also the only use cases i can think of so far are for ALB, API Gateway V1 and V2 (with the same API) and AppSync. |
@heitorlessa @saragerion Initially we would be the plans for the AppSync decorator? |
I'm happy with AppSync, just not with API Gateway as I need to think more carefully about it -- It can easily sprawl into a big thing e.g., cookies, body parser, etc. Feel free to make a PR @michaelbrewer |
yes, For all of the http proxy based handlers (ALB and API gateway), it can get very bloated. So I thought we could set the limit of what it can support. Like just request matching, getting the event as a data classes and return helper. All of the extra features we should point to Chalice. For AppSync, I will start moving it to the new location :) |
@heitorlessa ok the first one is there :) |
Thanks for adding more information @michaelbrewer! Very useful. One thing I would add on my side here is a consideration of how this would play out in the TypeScript tool and Lambda Node.js runtime. In TypeScript, utilities related to a particular AWS service will probably be separated into different distinct utilities/packages, thanks to the modularity of the Javascript SDK v3, also to optimize the size of the resulting Lambda. This modularity will likely have an impact on the implementation and the DX, which won't be exactly the same as Python. When it comes to porting this to other languages, I don't think we should expect that the implementation will be exactly the same and we probably need to make a case by case judgement. But no need to think about those already now if not necessary. |
yes, each language does have it's own ecosystem. That being said there are some common things that should be true.
Net result for me is that Powertools should both make development time much faster, make it easier for developers implement best practices but also runtime performance should be improved by allowing for fine grained control of what is shipped in the lambda runtime. |
FYI, the http proxy event handler is shaping up nicely too: The idea here is that you should be able to build out a lambda compatible with all http proxy events (ALB, API Gateway and all of its variations) |
Key information
Summary
Create an official utility
event_handler
for lightweight event handlersMotivation
Unofficially we have a very lightweight resolver for AppSync measuring only 50 lines of code, but still very useful. It would be nice to have a good location for these kind of utility and they should just depend on
data_classes
utilityProposal
Create a new top level utility for
event_handler
and then move the AppSync resolver and start to implement other useful ones like API Gateway Proxy Event Handler while ensuring we keeping them lightweight and only depend on existing Powertools librariesAppSync in python
API Gateway Proxy Example
Drawbacks
Over time Powertools could grow quite a lot as we add more features like this, so we should start to make this more modular (or aim for this as part of V2)
Rationale and alternatives
Unresolved questions
The text was updated successfully, but these errors were encountered: