Skip to content

Commit

Permalink
update to deep copy
Browse files Browse the repository at this point in the history
  • Loading branch information
sbiscigl committed Jan 9, 2025
1 parent 7e079b2 commit 4f9a138
Show file tree
Hide file tree
Showing 7 changed files with 209 additions and 283 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,34 +51,6 @@ namespace DynamoDB
static const char* GetServiceName();
static const char* GetAllocationTag();
inline const char* GetServiceClientName() const override { return "DynamoDB"; }

DynamoDBClient(const DynamoDBClient& other);

DynamoDBClient(DynamoDBClient&& other);

DynamoDBClient& operator=(const DynamoDBClient& other)
{
if(this == &other)
{
return *this;
}
AwsSmithyClientT::operator=(other);
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>::operator=(other);
init(m_clientConfiguration);
return *this;
}

DynamoDBClient& operator=(DynamoDBClient&& other)
{
if(this == &other)
{
return *this;
}
AwsSmithyClientT::operator=(std::move(other));
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>::operator=(std::move(other));
init(m_clientConfiguration);
return *this;
}

typedef DynamoDBClientConfiguration ClientConfigurationType;
typedef DynamoDBEndpointProvider EndpointProviderType;
Expand Down Expand Up @@ -2316,7 +2288,6 @@ namespace DynamoDB
std::shared_ptr<DynamoDBEndpointProviderBase>& accessEndpointProvider();
private:
friend class Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>;
void init(const DynamoDBClientConfiguration& clientConfiguration);

void OptionallyUpdateDescribeEndpointsCache(Aws::Endpoint::AWSEndpoint& resolvedEndpoint,
const Aws::String& operationName,
Expand Down
59 changes: 6 additions & 53 deletions generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ DynamoDBClient::DynamoDBClient(const DynamoDB::DynamoDBClientConfiguration& clie
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{GetServiceName(), clientConfiguration.region}},
})
{
init(m_clientConfiguration);
}
{}

DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
std::shared_ptr<DynamoDBEndpointProviderBase> endpointProvider,
Expand All @@ -132,9 +130,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::SimpleAwsCredentialIdentityResolver>(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}},
})
{
init(m_clientConfiguration);
}
{}

DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
std::shared_ptr<DynamoDBEndpointProviderBase> endpointProvider,
Expand All @@ -148,9 +144,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& cr
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{ Aws::MakeShared<smithy::AwsCredentialsProviderIdentityResolver>(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}}
})
{
init(m_clientConfiguration);
}
{}

/* Legacy constructors due deprecation */
DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfiguration) :
Expand All @@ -163,9 +157,7 @@ DynamoDBClient::DynamoDBClient(const Client::ClientConfiguration& clientConfigur
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::DefaultAwsCredentialIdentityResolver>(ALLOCATION_TAG), GetServiceName(), clientConfiguration.region}}
})
{
init(m_clientConfiguration);
}
{}

DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
const Client::ClientConfiguration& clientConfiguration) :
Expand All @@ -178,9 +170,7 @@ DynamoDBClient::DynamoDBClient(const AWSCredentials& credentials,
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::SimpleAwsCredentialIdentityResolver>(ALLOCATION_TAG, credentials), GetServiceName(), clientConfiguration.region}}
})
{
init(m_clientConfiguration);
}
{}

DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& credentialsProvider,
const Client::ClientConfiguration& clientConfiguration) :
Expand All @@ -193,9 +183,7 @@ DynamoDBClient::DynamoDBClient(const std::shared_ptr<AWSCredentialsProvider>& cr
{
{smithy::SigV4AuthSchemeOption::sigV4AuthSchemeOption.schemeId, smithy::SigV4AuthScheme{Aws::MakeShared<smithy::AwsCredentialsProviderIdentityResolver>(ALLOCATION_TAG, credentialsProvider), GetServiceName(), clientConfiguration.region}}
})
{
init(m_clientConfiguration);
}
{}
/* End of legacy constructors due deprecation */

DynamoDBClient::~DynamoDBClient()
Expand All @@ -208,47 +196,12 @@ std::shared_ptr<DynamoDBEndpointProviderBase>& DynamoDBClient::accessEndpointPro
return m_endpointProvider;
}

void DynamoDBClient::init(const DynamoDB::DynamoDBClientConfiguration& config)
{
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);
}

void DynamoDBClient::OverrideEndpoint(const Aws::String& endpoint)
{
AWS_CHECK_PTR(SERVICE_NAME, m_endpointProvider);
m_endpointProvider->OverrideEndpoint(endpoint);
}

DynamoDBClient::DynamoDBClient(const DynamoDBClient& other):
AwsSmithyClientT(
*other.m_clientConfig,
GetServiceName(),
Aws::Http::CreateHttpClient(other.m_clientConfiguration),
Aws::MakeShared<DynamoDBErrorMarshaller>(ALLOCATION_TAG),
other.m_endpointProvider,
Aws::MakeShared<smithy::SigV4AuthSchemeResolver<>>(ALLOCATION_TAG),
other.m_authSchemes),
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>(other)
{
init(m_clientConfiguration);
}

DynamoDBClient::DynamoDBClient(DynamoDBClient&& other):
AwsSmithyClientT(std::move(other)),
Aws::Client::ClientWithAsyncTemplateMethods<DynamoDBClient>(std::move(other))
{
init(m_clientConfiguration);
}

BatchExecuteStatementOutcome DynamoDBClient::BatchExecuteStatement(const BatchExecuteStatementRequest& request) const
{
AWS_OPERATION_GUARD(BatchExecuteStatement);
Expand Down
45 changes: 27 additions & 18 deletions src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,54 +30,60 @@ namespace client
typename EndpointProviderT,
typename SerializerT,
typename ResponseT,
typename MarshallerT>
typename ErrorMarshallerT>
class AwsSmithyClientT : public AwsSmithyClientBase
{
private:

public:
static_assert(std::is_base_of<Aws::Client::AWSErrorMarshaller, MarshallerT>::value, "MarshallerT must be derived from class Aws::Client::AWSErrorMarshaller");
static_assert(std::is_base_of<Aws::Client::AWSErrorMarshaller, ErrorMarshallerT>::value, "MarshallerT must be derived from class Aws::Client::AWSErrorMarshaller");

explicit AwsSmithyClientT(const ServiceClientConfigurationT& clientConfig, const Aws::String& serviceName,
const std::shared_ptr<Aws::Http::HttpClient>& httpClient,
const std::shared_ptr<Aws::Client::AWSErrorMarshaller>& errorMarshaller,
const std::shared_ptr<EndpointProviderT> endpointProvider,
const std::shared_ptr<ServiceAuthSchemeResolverT>& authSchemeResolver,
const Aws::UnorderedMap<Aws::String, AuthSchemesVariantT>& authSchemes)
: AwsSmithyClientBase(Aws::MakeShared<ServiceClientConfigurationT>(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller),
: AwsSmithyClientBase(Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, clientConfig), serviceName, httpClient, errorMarshaller),
m_clientConfiguration(*static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get())),
m_endpointProvider(endpointProvider),
m_authSchemeResolver(authSchemeResolver),
m_authSchemes(authSchemes),
m_serializer(Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider))
{
m_serviceName = ServiceNameT;
m_serviceName = ServiceNameT;
initClient();
}

AwsSmithyClientT(const AwsSmithyClientT& other):
AwsSmithyClientBase(Aws::MakeShared<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfig), other.m_serviceName, Aws::Http::CreateHttpClient(*other.m_clientConfig), Aws::MakeShared<MarshallerT>(other.m_serviceName.c_str())),
m_clientConfiguration{*static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get())},
m_endpointProvider{other.m_endpointProvider},
m_authSchemeResolver{other.m_authSchemeResolver},
AwsSmithyClientBase(other,
Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
ServiceNameT,
Aws::Http::CreateHttpClient(other.m_clientConfiguration),
Aws::MakeShared<ErrorMarshallerT>(ServiceNameT)),
m_clientConfiguration{*static_cast<ServiceClientConfigurationT*>(m_clientConfig.get())},
m_endpointProvider{Aws::MakeShared<EndpointProviderT>(ServiceNameT)},
m_authSchemeResolver{Aws::MakeShared<ServiceAuthSchemeResolverT>(ServiceNameT)},
m_authSchemes{other.m_authSchemes},
m_serializer{Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider)}
{
initClient();
}


AwsSmithyClientT& operator=(const AwsSmithyClientT& other)
{
if(this != &other)
{
AwsSmithyClientBase::operator=(other);
m_clientConfiguration = *static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get());
m_endpointProvider = other.m_endpointProvider;
m_authSchemeResolver = other.m_authSchemeResolver;
AwsSmithyClientBase::deepCopy(Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
ServiceNameT,
Aws::Http::CreateHttpClient(other.m_clientConfiguration),
Aws::MakeShared<ErrorMarshallerT>(other.m_serviceName.c_str()));
m_clientConfiguration = *static_cast<ServiceClientConfigurationT*>(m_clientConfig.get());
m_endpointProvider = Aws::MakeShared<EndpointProviderT>(other.m_serviceName);
m_authSchemeResolver = Aws::MakeShared<ServiceAuthSchemeResolverT>(other.m_serviceName);
m_authSchemes = other.m_authSchemes;
m_serializer = Aws::MakeShared<SerializerT>(other.m_serviceName.c_str(), m_clientConfiguration.telemetryProvider);
m_errorMarshaller = Aws::MakeShared<MarshallerT>(other.m_serviceName.c_str());
m_errorMarshaller = Aws::MakeShared<ErrorMarshallerT>(other.m_serviceName.c_str());
initClient();
}

return *this;
}

Expand All @@ -88,6 +94,10 @@ namespace client
virtual ~AwsSmithyClientT() = default;

protected:
void initClient() {
m_endpointProvider->InitBuiltInParameters(m_clientConfiguration);
}

inline const char* GetServiceClientName() const override { return m_serviceName.c_str(); }

ResolveEndpointOutcome ResolveEndpoint(const Aws::Endpoint::EndpointParameters& endpointParameters, EndpointUpdateCallback&& epCallback) const override
Expand Down Expand Up @@ -166,7 +176,6 @@ namespace client
return m_serializer->Deserialize(std::move(httpResponseOutcome), GetServiceClientName(), requestName);
}

protected:
ServiceClientConfigurationT& m_clientConfiguration;
std::shared_ptr<EndpointProviderT> m_endpointProvider{};
std::shared_ptr<ServiceAuthSchemeResolverT> m_authSchemeResolver{};
Expand Down
Loading

0 comments on commit 4f9a138

Please sign in to comment.