简体   繁体   English

lambda 可以在不关闭会话的情况下返回响应并等待新主体吗?

[英]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 FunctionAirflow

See what States you can leverage in the AWS Docs .在 AWS 文档中查看您可以利用的状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Lambda 返回响应后可以继续吗? - Can Lambda continue after returning response? 在 flutter 中的 Firestore 响应后自动关闭对话框 - Closing dialog automatically, after firestore response in flutter API Gateway + Lambda 极慢的响应时间 - API Gateway + Lambda extremely slower response time AWS api 网关在响应正文中返回令牌 - AWS api gateway returning token in the response body 在 React 中,return 语句是立即返回还是等待 UseEffect 完成? - In React, does a return statement return immediately or does it wait for the UseEffect to finish? AWS API Gateway 和 Lambda 返回图像 - AWS API Gateway and Lambda to return image 如何在使用来自 AWS Lambda 的 307 重定向(POST 方法和正文)在 python 中传递请求正文 - How to do pass a Request Body while doing a 307 Redirect with a( POST Method and body ) from AWS Lambda , in python 在没有输出文件的情况下调用aws lambda - Invoking aws lambda without output file SQS 在不先停止它的情况下触发 lambda - SQS triggering lambda without stopping it first 如何从 lambda 的 ALB 响应中删除标头 - How to remove headers form ALB response from lambda
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM