Skip to content

Commit 0d3aaa1

Browse files
committed
Add DynamoDB Streams retry tuning (25ms backoff, 4 max attempts)
Per the Retry Behavior 2.1 SEP, DynamoDB Streams uses the same retry tuning as DynamoDB: 25ms transient backoff base and 4 max attempts. Generate a DynamoDBStreamsClientConfiguration class with the retry factory instead of using the GenericClientConfiguration typedef.
1 parent 10c4804 commit 0d3aaa1

24 files changed

Lines changed: 360 additions & 21 deletions

File tree

generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClientConfiguration.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ void DynamoDBClientConfiguration::LoadDynamoDBSpecificConfig(const Aws::String&
3838
enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, inputProfileName);
3939
}
4040
this->configFactories.retryStrategyCreateFn = []() -> std::shared_ptr<Client::RetryStrategy> {
41-
// TODO: renable once default retries are evaluated
42-
// Align with other SDKs to default retry to 10 times for dynamodb.
43-
// return Client::InitRetryStrategy(10);
44-
return Client::InitRetryStrategy();
41+
return Client::InitRetryStrategy(4, "", 0.025);
4542
};
4643
}
4744

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#pragma once
7+
8+
#include <aws/core/client/GenericClientConfiguration.h>
9+
#include <aws/dynamodbstreams/DynamoDBStreams_EXPORTS.h>
10+
11+
namespace Aws {
12+
namespace DynamoDBStreams {
13+
struct AWS_DYNAMODBSTREAMS_API DynamoDBStreamsClientConfiguration : public Aws::Client::GenericClientConfiguration {
14+
using BaseClientConfigClass = Aws::Client::GenericClientConfiguration;
15+
16+
DynamoDBStreamsClientConfiguration(const Aws::Client::ClientConfigurationInitValues& configuration = {});
17+
18+
/**
19+
* Create a configuration based on settings in the aws configuration file for the given profile name.
20+
* The configuration file location can be set via the environment variable AWS_CONFIG_FILE
21+
* @param profileName the aws profile name.
22+
* @param shouldDisableIMDS whether or not to disable IMDS calls.
23+
*/
24+
DynamoDBStreamsClientConfiguration(const char* profileName, bool shouldDisableIMDS = false);
25+
26+
/**
27+
* Create a configuration with a predefined smart defaults
28+
* @param useSmartDefaults, required to differentiate c-tors
29+
* @param defaultMode, default mode to use
30+
* @param shouldDisableIMDS whether or not to disable IMDS calls.
31+
*/
32+
DynamoDBStreamsClientConfiguration(bool useSmartDefaults, const char* defaultMode = "legacy", bool shouldDisableIMDS = false);
33+
34+
/**
35+
* Converting constructors for compatibility with a legacy code
36+
*/
37+
DynamoDBStreamsClientConfiguration(const Aws::Client::ClientConfiguration& config);
38+
39+
private:
40+
void LoadDynamoDBStreamsSpecificConfig(const Aws::String& profileName);
41+
};
42+
} // namespace DynamoDBStreams
43+
} // namespace Aws

generated/src/aws-cpp-sdk-dynamodbstreams/include/aws/dynamodbstreams/DynamoDBStreamsEndpointProvider.h

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,30 @@
44
*/
55

66
#pragma once
7-
#include <aws/core/client/GenericClientConfiguration.h>
87
#include <aws/core/endpoint/DefaultEndpointProvider.h>
98
#include <aws/core/endpoint/EndpointParameter.h>
109
#include <aws/core/utils/memory/stl/AWSString.h>
1110
#include <aws/core/utils/memory/stl/AWSVector.h>
11+
#include <aws/dynamodbstreams/DynamoDBStreamsClientConfiguration.h>
1212
#include <aws/dynamodbstreams/DynamoDBStreamsEndpointRules.h>
1313
#include <aws/dynamodbstreams/DynamoDBStreams_EXPORTS.h>
1414

1515
namespace Aws {
1616
namespace DynamoDBStreams {
1717
namespace Endpoint {
18+
using DynamoDBStreamsClientConfiguration = Aws::DynamoDBStreams::DynamoDBStreamsClientConfiguration;
1819
using EndpointParameters = Aws::Endpoint::EndpointParameters;
1920
using Aws::Endpoint::DefaultEndpointProvider;
2021
using Aws::Endpoint::EndpointProviderBase;
2122

2223
using DynamoDBStreamsClientContextParameters = Aws::Endpoint::ClientContextParameters;
2324

24-
using DynamoDBStreamsClientConfiguration = Aws::Client::GenericClientConfiguration;
25-
using DynamoDBStreamsBuiltInParameters = Aws::Endpoint::BuiltInParameters;
25+
class AWS_DYNAMODBSTREAMS_API DynamoDBStreamsBuiltInParameters : public Aws::Endpoint::BuiltInParameters {
26+
public:
27+
virtual ~DynamoDBStreamsBuiltInParameters() {};
28+
using Aws::Endpoint::BuiltInParameters::SetFromClientConfiguration;
29+
virtual void SetFromClientConfiguration(const DynamoDBStreamsClientConfiguration& config);
30+
};
2631

2732
/**
2833
* The type for the DynamoDBStreams Client Endpoint Provider.
@@ -35,6 +40,24 @@ using DynamoDBStreamsEndpointProviderBase =
3540
using DynamoDBStreamsDefaultEpProviderBase =
3641
DefaultEndpointProvider<DynamoDBStreamsClientConfiguration, DynamoDBStreamsBuiltInParameters, DynamoDBStreamsClientContextParameters>;
3742

43+
} // namespace Endpoint
44+
} // namespace DynamoDBStreams
45+
46+
namespace Endpoint {
47+
/**
48+
* Export endpoint provider symbols for Windows DLL, otherwise declare as extern
49+
*/
50+
AWS_DYNAMODBSTREAMS_EXTERN template class AWS_DYNAMODBSTREAMS_API Aws::Endpoint::EndpointProviderBase<
51+
DynamoDBStreams::Endpoint::DynamoDBStreamsClientConfiguration, DynamoDBStreams::Endpoint::DynamoDBStreamsBuiltInParameters,
52+
DynamoDBStreams::Endpoint::DynamoDBStreamsClientContextParameters>;
53+
54+
AWS_DYNAMODBSTREAMS_EXTERN template class AWS_DYNAMODBSTREAMS_API Aws::Endpoint::DefaultEndpointProvider<
55+
DynamoDBStreams::Endpoint::DynamoDBStreamsClientConfiguration, DynamoDBStreams::Endpoint::DynamoDBStreamsBuiltInParameters,
56+
DynamoDBStreams::Endpoint::DynamoDBStreamsClientContextParameters>;
57+
} // namespace Endpoint
58+
59+
namespace DynamoDBStreams {
60+
namespace Endpoint {
3861
/**
3962
* Default endpoint provider used for this service
4063
*/

generated/src/aws-cpp-sdk-dynamodbstreams/include/aws/dynamodbstreams/DynamoDBStreamsServiceClientModel.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class RetryStrategy;
5151
} // namespace Client
5252

5353
namespace DynamoDBStreams {
54-
using DynamoDBStreamsClientConfiguration = Aws::Client::GenericClientConfiguration;
5554
using DynamoDBStreamsEndpointProviderBase = Aws::DynamoDBStreams::Endpoint::DynamoDBStreamsEndpointProviderBase;
5655
using DynamoDBStreamsEndpointProvider = Aws::DynamoDBStreams::Endpoint::DynamoDBStreamsEndpointProvider;
5756

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#include <aws/dynamodbstreams/DynamoDBStreamsClientConfiguration.h>
7+
8+
namespace Aws {
9+
namespace DynamoDBStreams {
10+
11+
void DynamoDBStreamsClientConfiguration::LoadDynamoDBStreamsSpecificConfig(const Aws::String& inputProfileName) {
12+
this->configFactories.retryStrategyCreateFn = []() -> std::shared_ptr<Client::RetryStrategy> {
13+
return Client::InitRetryStrategy(4, "", 0.025);
14+
};
15+
#if defined(_MSC_VER)
16+
(&reinterpret_cast<const int&>(inputProfileName));
17+
#else
18+
(void)(inputProfileName);
19+
#endif
20+
}
21+
22+
DynamoDBStreamsClientConfiguration::DynamoDBStreamsClientConfiguration(const Aws::Client::ClientConfigurationInitValues& configuration)
23+
: BaseClientConfigClass(configuration) {
24+
LoadDynamoDBStreamsSpecificConfig(this->profileName);
25+
}
26+
27+
DynamoDBStreamsClientConfiguration::DynamoDBStreamsClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS)
28+
: BaseClientConfigClass(inputProfileName, shouldDisableIMDS) {
29+
LoadDynamoDBStreamsSpecificConfig(Aws::String(inputProfileName));
30+
}
31+
32+
DynamoDBStreamsClientConfiguration::DynamoDBStreamsClientConfiguration(bool useSmartDefaults, const char* defaultMode,
33+
bool shouldDisableIMDS)
34+
: BaseClientConfigClass(useSmartDefaults, defaultMode, shouldDisableIMDS) {
35+
LoadDynamoDBStreamsSpecificConfig(this->profileName);
36+
}
37+
38+
DynamoDBStreamsClientConfiguration::DynamoDBStreamsClientConfiguration(const Aws::Client::ClientConfiguration& config)
39+
: BaseClientConfigClass(config) {
40+
LoadDynamoDBStreamsSpecificConfig(this->profileName);
41+
}
42+
43+
} // namespace DynamoDBStreams
44+
} // namespace Aws

generated/src/aws-cpp-sdk-dynamodbstreams/source/DynamoDBStreamsEndpointProvider.cpp

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,27 @@
66
#include <aws/dynamodbstreams/DynamoDBStreamsEndpointProvider.h>
77

88
namespace Aws {
9+
#ifndef AWS_DYNAMODBSTREAMS_EXPORTS // Except for Windows DLL
10+
namespace Endpoint {
11+
/**
12+
* Instantiate endpoint providers
13+
*/
14+
template class Aws::Endpoint::EndpointProviderBase<DynamoDBStreams::Endpoint::DynamoDBStreamsClientConfiguration,
15+
DynamoDBStreams::Endpoint::DynamoDBStreamsBuiltInParameters,
16+
DynamoDBStreams::Endpoint::DynamoDBStreamsClientContextParameters>;
17+
18+
template class Aws::Endpoint::DefaultEndpointProvider<DynamoDBStreams::Endpoint::DynamoDBStreamsClientConfiguration,
19+
DynamoDBStreams::Endpoint::DynamoDBStreamsBuiltInParameters,
20+
DynamoDBStreams::Endpoint::DynamoDBStreamsClientContextParameters>;
21+
} // namespace Endpoint
22+
#endif
23+
924
namespace DynamoDBStreams {
10-
namespace Endpoint {} // namespace Endpoint
25+
namespace Endpoint {
26+
void DynamoDBStreamsBuiltInParameters::SetFromClientConfiguration(const DynamoDBStreamsClientConfiguration& config) {
27+
SetFromClientConfiguration(static_cast<const DynamoDBStreamsClientConfiguration::BaseClientConfigClass&>(config));
28+
}
29+
30+
} // namespace Endpoint
1131
} // namespace DynamoDBStreams
1232
} // namespace Aws

generated/src/aws-cpp-sdk-sqs/source/SQSClient.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,9 @@ PurgeQueueOutcome SQSClient::PurgeQueue(const PurgeQueueRequest& request) const
275275
}
276276

277277
ReceiveMessageOutcome SQSClient::ReceiveMessage(const ReceiveMessageRequest& request) const {
278+
auto longPollParams = Aws::MakeShared<Aws::Http::ServiceSpecificParameters>("SQSClient");
279+
longPollParams->parameterMap.emplace("isLongPollingOperation", "true");
280+
request.SetServiceSpecificParameters(longPollParams);
278281
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
279282
return result.IsSuccess() ? ReceiveMessageOutcome(result.GetResultWithOwnership()) : ReceiveMessageOutcome(std::move(result.GetError()));
280283
}

generated/src/aws-cpp-sdk-states/source/SFNClient.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ DescribeStateMachineForExecutionOutcome SFNClient::DescribeStateMachineForExecut
283283
}
284284

285285
GetActivityTaskOutcome SFNClient::GetActivityTask(const GetActivityTaskRequest& request) const {
286+
auto longPollParams = Aws::MakeShared<Aws::Http::ServiceSpecificParameters>("SFNClient");
287+
longPollParams->parameterMap.emplace("isLongPollingOperation", "true");
288+
request.SetServiceSpecificParameters(longPollParams);
286289
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
287290
return result.IsSuccess() ? GetActivityTaskOutcome(result.GetResultWithOwnership())
288291
: GetActivityTaskOutcome(std::move(result.GetError()));

generated/src/aws-cpp-sdk-swf/source/SWFClient.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,12 +327,18 @@ ListWorkflowTypesOutcome SWFClient::ListWorkflowTypes(const ListWorkflowTypesReq
327327
}
328328

329329
PollForActivityTaskOutcome SWFClient::PollForActivityTask(const PollForActivityTaskRequest& request) const {
330+
auto longPollParams = Aws::MakeShared<Aws::Http::ServiceSpecificParameters>("SWFClient");
331+
longPollParams->parameterMap.emplace("isLongPollingOperation", "true");
332+
request.SetServiceSpecificParameters(longPollParams);
330333
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
331334
return result.IsSuccess() ? PollForActivityTaskOutcome(result.GetResultWithOwnership())
332335
: PollForActivityTaskOutcome(std::move(result.GetError()));
333336
}
334337

335338
PollForDecisionTaskOutcome SWFClient::PollForDecisionTask(const PollForDecisionTaskRequest& request) const {
339+
auto longPollParams = Aws::MakeShared<Aws::Http::ServiceSpecificParameters>("SWFClient");
340+
longPollParams->parameterMap.emplace("isLongPollingOperation", "true");
341+
request.SetServiceSpecificParameters(longPollParams);
336342
auto result = InvokeServiceOperation(request, Aws::Http::HttpMethod::HTTP_POST);
337343
return result.IsSuccess() ? PollForDecisionTaskOutcome(result.GetResultWithOwnership())
338344
: PollForDecisionTaskOutcome(std::move(result.GetError()));

generated/tests/dynamodbstreams-gen-tests/DynamoDBStreamsIncludeTests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <aws/testing/AwsTestHelpers.h>
88

99
#include <aws/dynamodbstreams/DynamoDBStreamsClient.h>
10+
#include <aws/dynamodbstreams/DynamoDBStreamsClientConfiguration.h>
1011
#include <aws/dynamodbstreams/DynamoDBStreamsEndpointProvider.h>
1112
#include <aws/dynamodbstreams/DynamoDBStreamsEndpointRules.h>
1213
#include <aws/dynamodbstreams/DynamoDBStreamsErrorMarshaller.h>

0 commit comments

Comments
 (0)