[英]Can a lambda return a response and wait for a new body without closing the session?
I am running a puppeteer function in AWS Lambda and I have a scenario that the user makes a POST request to the lambda with his username and email.我在 AWS Lambda 中运行一个 puppeteer 函数,我有一个场景,用户使用他的用户名和电子邮件向 lambda 发出 POST 请求。 The function is going to check if they are valid in a website and return the JSON to the user with the answer.该函数将检查它们在网站中是否有效,并将带有答案的 JSON 返回给用户。 Is it possible to use the same lambda session to receive another input/body from the user?是否可以使用相同的 lambda 会话从用户接收另一个输入/正文?
The reason I need it to be the same session is because each time an user and email is sent to the lambda, the puppeteer website is going to generate unique ID's that need to be used AFTER the user sends his data in that exact moment because it is logged into the website with an unique session.我需要它成为同一会话的原因是因为每次将用户和电子邮件发送到 lambda 时,puppeteer 网站将生成唯一的 ID,需要在用户在那一刻发送他的数据后使用,因为它使用唯一会话登录网站。
I'm currently running this function in a NodeJS and it is fine because the session isnt going to be closed but the session is closed once the lambda returns the first response.我目前正在 NodeJS 中运行此函数,这很好,因为会话不会关闭,但一旦 lambda 返回第一个响应,会话就会关闭。
Like people mentioned above, Lambda function is stateless resource and you can ultimately use dynamoDB to store any values such session ID or so.就像上面提到的人一样,Lambda 函数是无状态资源,您最终可以使用 dynamoDB 来存储任何值,例如会话 ID 等。
Additionally, if the Lambda function should wait for response or any updated values by querying DynamoDB, then you can implement AWS Step Function or Airflow which provides the "wait" state.此外,如果 Lambda 函数应该通过查询 DynamoDB 等待响应或任何更新的值,那么您可以实施提供“等待”状态的 AWS Step Function或Airflow 。
See what States you can leverage in the AWS Docs .在 AWS 文档中查看您可以利用的状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.