jordaneremieff / mangum

AWS Lambda support for ASGI applications
https://mangum.io/
MIT License
1.67k stars 119 forks source link

Using serverless warmup plugin with mangum #266

Closed ApurvaMisra closed 2 years ago

ApurvaMisra commented 2 years ago

What would be the best way for Mangum to respond based on the event source? I want to modify the event handler, such that it responds without doing any processing if the event is from the below source
{ "Event": { "source": "serverless-plugin-warmup" } }

The aim is to reduce the time the lambda is occupied for when invoked by the warmer lambda. Here is the link for the plugin: https://www.serverless.com/plugins/serverless-plugin-warmup image

jordaneremieff commented 2 years ago

Hi @ApurvaMisra, this can be accomplished by using a function that returns the handler instance as demonstrated here.

See also this comment for a similar use-case that may help clarify things further.