Serverless with AWS Lambda Node Lambda Context
Transcript from the "Node Lambda Context" Lesson
>> Instructor: So here's a function. You can see it's literally a handler. It takes an event and a callback. Okay, this is advance, man, I don't wanna talk about this. Okay, I'm gonna talk about it. This right here is a node-specific thing in Lambda, only for a node, because it's asynchronous.
[00:00:58] By default, the Lambda is going to continue to be open until there's nothing left on that asynch table basically. This tells it to ignore that. Just when I call done, be done. When I run this call back, just cut it off, I don't care if there's anything hanging in the background.
[00:01:17] This is useful for database connections. So if you connect to something pretty much anything other than dynamo DV and Lambda, which is why I did not talk about databases in this course, because it's extremely complicated. You will have to do this, otherwise a database connection is a long lift connection and if you call the call back inside of a lambda, it still won't exit because there's still asynchronous things hanging there at the background, your database connection.
[00:01:41] This tells Lambda to ignore that database connection and exit anyway. So very complicated, that's what that first line is. And then if we just look, you can see it's kinda just. I mean, what is it doing here? It looks like it's making a request object. It's waiting for the next tick.
[00:01:59] Yeah, it's basically just simulating requests, I mean, I'm sorry, it's just simulating express. It's pretty simple here. So yeah, nothing too fancy, but yeah, that's basically what it's doing. It's satisfying whatever expressed needs, but in the context of the Lambda's arguments.