awslabs / awslabs/aws-lambda-cpp

Question about timeouts

未關閉
#119 4 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
主要語言
C++
星號
465
分支
98
平均合併
12 小時 47 分鐘
30 天內合併 PR
3

描述

Hello,

I have followed the examples here: https://aws.amazon.com/blogs/compute/introducing-the-c-lambda-runtime/

When I run my internal execution so that it takes 5 seconds everything works fine. But when I run it for 70 seconds I never get any response and the lambda function seems to be restarting several times. My guess is that is has to do with some timeouts. But how do I configure them? I cannot find any good developer reference.

```
static invocation_response my_handler(invocation_request const& req, Aws::S3::S3Client const& client) {
using namespace Aws::Utils::Json;
JsonValue json(req.payload);
if (!json.WasParseSuccessful()) {
return invocation_response::failure("Failed to parse input JSON", "InvalidJSON");
}

auto v = json.View();

if (!v.ValueExists("s3bucket") || !v.ValueExists("s3key") || !v.GetObject("s3bucket").IsString() ||
!v.GetObject("s3key").IsString()) {
return invocation_response::failure("Missing input value s3bucket or s3key", "InvalidJSON");
}

auto bucket = v.GetString("s3bucket");
auto key = v.GetString("s3key");

AWS_LOGSTREAM_INFO(TAG, "Attempting to download file from s3://" << bucket << "/" << key);

// Internal execution about 70 seconds...
string response = "Success!";

return invocation_response::success("We did it! Response: " + response, "application/json");
}

std::function()> GetConsoleLoggerFactory() {
return [] {
return Aws::MakeShared(
"console_logger", Aws::Utils::Logging::LogLevel::Info);
};
}

Aws::Client::ClientConfiguration getS3Config() {

Aws::Client::ClientConfiguration config;
config.region = "us-east-1";
config.scheme = Aws::Http::Scheme::HTTP;

return config;
}

Aws::Client::ClientConfiguration getS3ConfigWithBundle() {

cout << "USING S3 REGION: " << Aws::Environment::GetEnv("AWS_REGION") << endl;

Aws::Client::ClientConfiguration config;
config.region = Aws::Environment::GetEnv("AWS_REGION");
config.scheme = Aws::Http::Scheme::HTTP;

return config;
}

void run_lambda_handler() {

Aws::S3::S3Client client(getS3ConfigWithBundle());
auto handler_fn = [&client](aws::lambda_runtime::invocation_request const& req) {
return my_handler(req, client);
};
run_handler(handler_fn);
}

int main(int argc, const char **argv) {
Aws::SDKOptions options;
options.loggingOptions.logLevel = Aws::Utils::Logging::LogLevel::Info;
options.loggingOptions.logger_create_fn = GetConsoleLoggerFactory();
Aws::InitAPI(options);

run_lambda_handler();

Aws::ShutdownAPI(options);

return 0;
}
```

貢獻指南

開啟貢獻指南

研究方向

從 AWS Lambda C++ runtime 範例以及 issue 中顯示的 run_handler 呼叫開始;重現 5 秒執行與 70 秒執行之間的差異。確定逾時行為和設定記錄在哪裡,然後讓相關的開發者參考足夠清楚,以解釋觀察到的重新啟動和設定選項。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
aws, cpp
領域
cloud
Issue 類型
文件
難度
5/5
預估耗時
一週以上
活躍度
停滯
描述清晰度
需要釐清
新手友好度
25/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。