a.raya203
a.raya203

Reputation: 115

AWS S3: How to set maximum number of retries in C++?

I have a typical example of an S3 upload which works just fine. I decided to set a limit on the number of retries since sometimes due to network issues, the delay causes problems. I looked at the AWS SDK and apparently there is a MaxErrorRetry option I can set for the client configuration. However, that doesn't seem to be an option in C++. Instead, I found a RetryStrategy function, but i'm not sure how to use it. All I need to do is to set a number for the amount of retries instead of resulting to the default. Any advice?

Thanks

Upvotes: 0

Views: 1689

Answers (2)

Sarfraz Siddiqui
Sarfraz Siddiqui

Reputation: 21

long maxRetry = 2;                                                                      
long scope = 2;
std::shared_ptr<Aws::Client::DefaultRetryStrategy> retryStrategy = std::make_shared<Aws::Client::DefaultRetryStrategy>(maxRetry,scope); // strategy with custom max retries

Aws::Client::ClientConfiguration clientConfig;
clientConfig.retryStrategy = retryStrategy; // assign it to Client configuration

Aws::S3::S3Client s3Client(clientConfig); // create S3 client with your configuration

Upvotes: 2

a.raya203
a.raya203

Reputation: 115

Found the answer:

std::shared_ptr<Aws::Client::RetryStrategy> retry; // initialise retry strategy 
retry.reset(new Aws::Client::DefaultRetryStrategy(num_of_retries, scope));//override default by creating an instance of DefaultRetryStrategy
client_config.retryStrategy = retry; // assign to client_config

Upvotes: 0

Related Questions