Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3084: use factories for client utility classes initialization, better shutdown #3087

Merged
merged 2 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3980,7 +3980,6 @@ namespace CognitoIdentityProvider
void init(const CognitoIdentityProviderClientConfiguration& clientConfiguration);

CognitoIdentityProviderClientConfiguration m_clientConfiguration;
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor;
std::shared_ptr<CognitoIdentityProviderEndpointProviderBase> m_endpointProvider;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ CognitoIdentityProviderClient::CognitoIdentityProviderClient(const CognitoIdenti
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CognitoIdentityProviderErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<CognitoIdentityProviderEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -174,7 +173,6 @@ CognitoIdentityProviderClient::CognitoIdentityProviderClient(const AWSCredential
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CognitoIdentityProviderErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<CognitoIdentityProviderEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -190,7 +188,6 @@ CognitoIdentityProviderClient::CognitoIdentityProviderClient(const std::shared_p
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CognitoIdentityProviderErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<CognitoIdentityProviderEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -205,7 +202,6 @@ CognitoIdentityProviderClient::CognitoIdentityProviderClient(const std::shared_p
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CognitoIdentityProviderErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<CognitoIdentityProviderEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -220,7 +216,6 @@ CognitoIdentityProviderClient::CognitoIdentityProviderClient(const AWSCredential
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CognitoIdentityProviderErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<CognitoIdentityProviderEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -235,7 +230,6 @@ CognitoIdentityProviderClient::CognitoIdentityProviderClient(const std::shared_p
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CognitoIdentityProviderErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<CognitoIdentityProviderEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -255,6 +249,14 @@ std::shared_ptr<CognitoIdentityProviderEndpointProviderBase>& CognitoIdentityPro
void CognitoIdentityProviderClient::init(const CognitoIdentityProvider::CognitoIdentityProviderClientConfiguration& config)
{
AWSClient::SetServiceClientName("Cognito Identity Provider");
if (!m_clientConfiguration.executor) {
if (!m_clientConfiguration.configFactories.executorCreateFn()) {
AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn");
m_isInitialized = false;
return;
}
m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn();
}
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
m_endpointProvider->InitBuiltInParameters(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2256,7 +2256,6 @@ namespace DynamoDB

mutable Aws::Utils::ConcurrentCache<Aws::String, Aws::String> m_endpointsCache;
DynamoDBClientConfiguration m_clientConfiguration;
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor;
std::shared_ptr<DynamoDBEndpointProviderBase> m_endpointProvider;
};

Expand Down
14 changes: 8 additions & 6 deletions generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ DynamoDBClient::DynamoDBClient(const DynamoDB::DynamoDBClientConfiguration& clie
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -129,7 +128,6 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -145,7 +143,6 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& cr
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -160,7 +157,6 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& cr
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -175,7 +171,6 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -190,7 +185,6 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& cr
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<DynamoDBEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -210,6 +204,14 @@ std::shared_ptr<DynamoDBEndpointProviderBase>& DynamoDBClient::accessEndpointPro
void DynamoDBClient::init(const DynamoDB::DynamoDBClientConfiguration& config)
{
AWSClient::SetServiceClientName("DynamoDB");
if (!m_clientConfiguration.executor) {
if (!m_clientConfiguration.configFactories.executorCreateFn()) {
AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn");
m_isInitialized = false;
return;
}
m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn();
}
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
m_endpointProvider->InitBuiltInParameters(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,6 @@ namespace CloudWatchLogs
void init(const CloudWatchLogsClientConfiguration& clientConfiguration);

CloudWatchLogsClientConfiguration m_clientConfiguration;
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor;
std::shared_ptr<CloudWatchLogsEndpointProviderBase> m_endpointProvider;
};

Expand Down
14 changes: 8 additions & 6 deletions generated/src/aws-cpp-sdk-logs/source/CloudWatchLogsClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ CloudWatchLogsClient::CloudWatchLogsClient(const CloudWatchLogs::CloudWatchLogsC
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CloudWatchLogsErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<CloudWatchLogsEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -143,7 +142,6 @@ CloudWatchLogsClient::CloudWatchLogsClient(const AWSCredentials& credentials,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CloudWatchLogsErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<CloudWatchLogsEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -159,7 +157,6 @@ CloudWatchLogsClient::CloudWatchLogsClient(const std::shared_ptr<AWSCredentialsP
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CloudWatchLogsErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<CloudWatchLogsEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -174,7 +171,6 @@ CloudWatchLogsClient::CloudWatchLogsClient(const std::shared_ptr<AWSCredentialsP
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CloudWatchLogsErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<CloudWatchLogsEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -189,7 +185,6 @@ CloudWatchLogsClient::CloudWatchLogsClient(const AWSCredentials& credentials,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CloudWatchLogsErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<CloudWatchLogsEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -204,7 +199,6 @@ CloudWatchLogsClient::CloudWatchLogsClient(const std::shared_ptr<AWSCredentialsP
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<CloudWatchLogsErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<CloudWatchLogsEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -224,6 +218,14 @@ std::shared_ptr<CloudWatchLogsEndpointProviderBase>& CloudWatchLogsClient::acces
void CloudWatchLogsClient::init(const CloudWatchLogs::CloudWatchLogsClientConfiguration& config)
{
AWSClient::SetServiceClientName("CloudWatch Logs");
if (!m_clientConfiguration.executor) {
if (!m_clientConfiguration.configFactories.executorCreateFn()) {
AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn");
m_isInitialized = false;
return;
}
m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn();
}
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
m_endpointProvider->InitBuiltInParameters(config);
}
Expand Down
1 change: 0 additions & 1 deletion generated/src/aws-cpp-sdk-rds/include/aws/rds/RDSClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -5253,7 +5253,6 @@ namespace Aws
void init(const RDSClientConfiguration& clientConfiguration);

RDSClientConfiguration m_clientConfiguration;
std::shared_ptr<Aws::Utils::Threading::Executor> m_executor;
std::shared_ptr<RDSEndpointProviderBase> m_endpointProvider;
};
} // namespace RDS
Expand Down
14 changes: 8 additions & 6 deletions generated/src/aws-cpp-sdk-rds/source/RDSClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ RDSClient::RDSClient(const RDS::RDSClientConfiguration& clientConfiguration,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<RDSErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<RDSEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -234,7 +233,6 @@ RDSClient::RDSClient(const AWSCredentials& credentials,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<RDSErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<RDSEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -250,7 +248,6 @@ RDSClient::RDSClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsP
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<RDSErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(endpointProvider ? std::move(endpointProvider) : Aws::MakeShared<RDSEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -265,7 +262,6 @@ RDSClient::RDSClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsP
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<RDSErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<RDSEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -280,7 +276,6 @@ RDSClient::RDSClient(const AWSCredentials& credentials,
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<RDSErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<RDSEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -295,7 +290,6 @@ RDSClient::RDSClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsP
Aws::Region::ComputeSignerRegion(clientConfiguration.region)),
Aws::MakeShared<RDSErrorMarshaller>(ALLOCATION_TAG)),
m_clientConfiguration(clientConfiguration),
m_executor(clientConfiguration.executor),
m_endpointProvider(Aws::MakeShared<RDSEndpointProvider>(ALLOCATION_TAG))
{
init(m_clientConfiguration);
Expand All @@ -315,6 +309,14 @@ std::shared_ptr<RDSEndpointProviderBase>& RDSClient::accessEndpointProvider()
void RDSClient::init(const RDS::RDSClientConfiguration& config)
{
AWSClient::SetServiceClientName("RDS");
if (!m_clientConfiguration.executor) {
if (!m_clientConfiguration.configFactories.executorCreateFn()) {
AWS_LOGSTREAM_FATAL(ALLOCATION_TAG, "Failed to initialize client: config is missing Executor or executorCreateFn");
m_isInitialized = false;
return;
}
m_clientConfiguration.executor = m_clientConfiguration.configFactories.executorCreateFn();
}
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
m_endpointProvider->InitBuiltInParameters(config);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6382,7 +6382,6 @@ namespace Aws
const Aws::AmazonWebServiceRequest *request,
const Aws::Http::URI &uri, Aws::Http::HttpMethod method) const;
S3Crt::ClientConfiguration m_clientConfiguration;
std::shared_ptr<Utils::Threading::Executor> m_executor;
struct aws_s3_client* m_s3CrtClient = {};
struct aws_signing_config_aws m_s3CrtSigningConfig = {};
struct CrtClientShutdownCallbackDataWrapper m_wrappedData = {};
Expand Down
Loading
Loading