I'm writing a slack bot with Go and Aws Lambda. Slack requires for the bot to reply within 3 seconds. However, sometimes I can't make it reply that fast, cuz it's "talking" to other serverless applications for requesting some data or dispatching tasks. I have never worked with goroutines before, but I was hoping that I could implement something like this:
I'm not sure if that's even possible.
I've read about sync.WaitGroup
, but I'm not sure how to incorporate it together with main function. Should I use it inside the handler? But I need to return
response and that's not a function that I can wrap into a goroutine.
Ideally, I would like for handler to reply right away and then process goroutine in the background.
Don't try to do anything in your lambda handler after the request finishes.
A more reliable approach:
response_url