Skip to content

Commit 8d9f41a

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 0579caf commit 8d9f41a

8 files changed

Lines changed: 139 additions & 11 deletions

File tree

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/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>

tools/code-generation/generator/src/main/java/com/amazonaws/util/awsclientgenerator/domainmodels/codegeneration/ServiceModel.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ public boolean hasServiceSpecificClientConfig() {
9191
return metadata.getServiceId().equalsIgnoreCase("S3") ||
9292
metadata.getServiceId().equalsIgnoreCase("S3-CRT") ||
9393
metadata.getServiceId().equalsIgnoreCase("S3 Control") ||
94+
metadata.getServiceId().equalsIgnoreCase("DynamoDB Streams") ||
9495
metadata.getSigningName().equalsIgnoreCase("bedrock") ||
9596
metadata.isHasEndpointDiscoveryTrait() ||
9697
endpointRuleSetModel.getParameters().containsKey("AccountId") || endpointRuleSetModel.getParameters().containsKey("AccountIdEndpointMode");

tools/code-generation/generator/src/main/resources/com/amazonaws/util/awsclientgenerator/velocity/cpp/common/ServiceClientConfigurationSource.vm

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,10 @@ void ${metadata.classNamePrefix}ClientConfiguration::Load${serviceNamespace}Spec
130130
enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, inputProfileName);
131131
}
132132
#end
133-
## DyanmoDB historically requires 10 retries for backwards compatibility
134-
#if($serviceModel.metadata.serviceId == "DynamoDB")
133+
## DynamoDB and DynamoDB Streams tune retry 2.1: maxAttempts=4 and a 25ms non-throttling backoff base
134+
#if($serviceModel.metadata.serviceId == "DynamoDB" || $serviceModel.metadata.serviceId == "DynamoDB Streams")
135135
this->configFactories.retryStrategyCreateFn = []() -> std::shared_ptr<Client::RetryStrategy> {
136-
// TODO: renable once default retries are evaluated
137-
// Align with other SDKs to default retry to 10 times for dynamodb.
138-
// return Client::InitRetryStrategy(10);
139-
return Client::InitRetryStrategy();
136+
return Client::InitRetryStrategy(4, "", 0.025);
140137
};
141138
#end
142139
## Bedrock API key auth

0 commit comments

Comments
 (0)