Repository navigation
Expand file tree
/
Copy pathDynamoDBClientConfiguration.cpp
More file actions
72 lines (60 loc) · 3.07 KB
/
Copy pathDynamoDBClientConfiguration.cpp
File metadata and controls
72 lines (60 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
#include <aws/dynamodb/DynamoDBClientConfiguration.h>
namespace Aws {
namespace DynamoDB {
bool IsEndpointDiscoveryEnabled(const Aws::String& endpointOverride, const Aws::String& profileName) {
bool enabled = false;
if (!endpointOverride.empty()) {
enabled = false;
} else {
static const char* AWS_ENABLE_ENDPOINT_DISCOVERY_ENV_KEY = "AWS_ENABLE_ENDPOINT_DISCOVERY";
static const char* AWS_ENABLE_ENDPOINT_DISCOVERY_PROFILE_KEY = "endpoint_discovery_enabled";
static const char* AWS_EP_DISCOVERY_ENABLED = "true";
static const char* AWS_EP_DISCOVERY_DISABLED = "false";
static const char* DEFAULT_VALUE_FOR_DYNAMODB = AWS_EP_DISCOVERY_DISABLED;
Aws::String configVal = Client::ClientConfiguration::LoadConfigFromEnvOrProfile(
AWS_ENABLE_ENDPOINT_DISCOVERY_ENV_KEY, profileName, AWS_ENABLE_ENDPOINT_DISCOVERY_PROFILE_KEY,
{AWS_EP_DISCOVERY_ENABLED, AWS_EP_DISCOVERY_DISABLED}, DEFAULT_VALUE_FOR_DYNAMODB);
if (AWS_EP_DISCOVERY_ENABLED == configVal) {
enabled = true;
} else if (AWS_EP_DISCOVERY_DISABLED == configVal) {
enabled = false;
}
}
return enabled;
}
void DynamoDBClientConfiguration::LoadDynamoDBSpecificConfig(const Aws::String& inputProfileName) {
if (!enableEndpointDiscovery) {
enableEndpointDiscovery = IsEndpointDiscoveryEnabled(this->endpointOverride, inputProfileName);
}
const Aws::String retryProfileName = this->profileName;
this->configFactories.retryStrategyCreateFn = [retryProfileName]() -> std::shared_ptr<Client::RetryStrategy> {
Client::InitRetryStrategyOptions options;
options.maxAttempts = 4;
options.transientBackoffBaseSec = 0.025;
options.profileName = retryProfileName;
return Client::InitRetryStrategy(options);
};
}
DynamoDBClientConfiguration::DynamoDBClientConfiguration(const Aws::Client::ClientConfigurationInitValues& configuration)
: BaseClientConfigClass(configuration), enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery) {
LoadDynamoDBSpecificConfig(this->profileName);
}
DynamoDBClientConfiguration::DynamoDBClientConfiguration(const char* inputProfileName, bool shouldDisableIMDS)
: BaseClientConfigClass(inputProfileName, shouldDisableIMDS), enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery) {
LoadDynamoDBSpecificConfig(Aws::String(inputProfileName));
}
DynamoDBClientConfiguration::DynamoDBClientConfiguration(bool useSmartDefaults, const char* defaultMode, bool shouldDisableIMDS)
: BaseClientConfigClass(useSmartDefaults, defaultMode, shouldDisableIMDS),
enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery) {
LoadDynamoDBSpecificConfig(this->profileName);
}
DynamoDBClientConfiguration::DynamoDBClientConfiguration(const Aws::Client::ClientConfiguration& config)
: BaseClientConfigClass(config), enableEndpointDiscovery(ClientConfiguration::enableEndpointDiscovery) {
LoadDynamoDBSpecificConfig(this->profileName);
}
} // namespace DynamoDB
} // namespace Aws