mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-23 06:26:15 +02:00
Log AWS retries
This commit is contained in:
parent
5789b692d4
commit
df66d346df
1 changed files with 14 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <aws/core/Aws.h>
|
#include <aws/core/Aws.h>
|
||||||
#include <aws/core/client/ClientConfiguration.h>
|
#include <aws/core/client/ClientConfiguration.h>
|
||||||
|
#include <aws/core/client/DefaultRetryStrategy.h>
|
||||||
#include <aws/s3/S3Client.h>
|
#include <aws/s3/S3Client.h>
|
||||||
#include <aws/s3/model/CreateBucketRequest.h>
|
#include <aws/s3/model/CreateBucketRequest.h>
|
||||||
#include <aws/s3/model/GetBucketLocationRequest.h>
|
#include <aws/s3/model/GetBucketLocationRequest.h>
|
||||||
|
@ -57,12 +58,25 @@ S3Helper::S3Helper()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Log AWS retries. */
|
||||||
|
class RetryStrategy : public Aws::Client::DefaultRetryStrategy
|
||||||
|
{
|
||||||
|
long CalculateDelayBeforeNextRetry(const Aws::Client::AWSError<Aws::Client::CoreErrors>& error, long attemptedRetries) const override
|
||||||
|
{
|
||||||
|
auto res = Aws::Client::DefaultRetryStrategy::CalculateDelayBeforeNextRetry(error, attemptedRetries);
|
||||||
|
printError("AWS error '%s' (%s), will retry in %d ms",
|
||||||
|
error.GetExceptionName(), error.GetMessage(), res);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
ref<Aws::Client::ClientConfiguration> S3Helper::makeConfig()
|
ref<Aws::Client::ClientConfiguration> S3Helper::makeConfig()
|
||||||
{
|
{
|
||||||
initAWS();
|
initAWS();
|
||||||
auto res = make_ref<Aws::Client::ClientConfiguration>();
|
auto res = make_ref<Aws::Client::ClientConfiguration>();
|
||||||
res->region = Aws::Region::US_EAST_1; // FIXME: make configurable
|
res->region = Aws::Region::US_EAST_1; // FIXME: make configurable
|
||||||
res->requestTimeoutMs = 600 * 1000;
|
res->requestTimeoutMs = 600 * 1000;
|
||||||
|
res->retryStrategy = std::make_shared<RetryStrategy>();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue