diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2017-02-21T10·42+0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2017-02-21T10·50+0100 |
commit | df66d346dfc3c1d1136256ea58d0419d12599a50 (patch) | |
tree | f8ccdeb4db806095c073ade0a78896abc5c54d37 /src/libstore | |
parent | 5789b692d4b0a74f5804a1dfdb4b1f429ab877ea (diff) |
Log AWS retries
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/s3-binary-cache-store.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc index ac083410b353..041c68c6816f 100644 --- a/src/libstore/s3-binary-cache-store.cc +++ b/src/libstore/s3-binary-cache-store.cc @@ -8,6 +8,7 @@ #include <aws/core/Aws.h> #include <aws/core/client/ClientConfiguration.h> +#include <aws/core/client/DefaultRetryStrategy.h> #include <aws/s3/S3Client.h> #include <aws/s3/model/CreateBucketRequest.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() { initAWS(); auto res = make_ref<Aws::Client::ClientConfiguration>(); res->region = Aws::Region::US_EAST_1; // FIXME: make configurable res->requestTimeoutMs = 600 * 1000; + res->retryStrategy = std::make_shared<RetryStrategy>(); return res; } |