Skip to content

Commit

Permalink
config deep copy changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sbera87 committed Jan 7, 2025
1 parent fb301fe commit b7441f0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ namespace client

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{other.m_clientConfiguration},
m_clientConfiguration{*static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get())},
m_endpointProvider{other.m_endpointProvider},
m_authSchemeResolver{other.m_authSchemeResolver},
m_authSchemes{other.m_authSchemes},
Expand All @@ -70,7 +70,7 @@ namespace client
if(this != &other)
{
AwsSmithyClientBase::operator=(other);
m_clientConfiguration = other.m_clientConfiguration;
m_clientConfiguration = *static_cast<ServiceClientConfigurationT*>(AwsSmithyClientBase::m_clientConfig.get());
m_endpointProvider = other.m_endpointProvider;
m_authSchemeResolver = other.m_authSchemeResolver;
m_authSchemes = other.m_authSchemes;
Expand Down Expand Up @@ -167,7 +167,7 @@ namespace client
}

protected:
ServiceClientConfigurationT m_clientConfiguration;
ServiceClientConfigurationT& m_clientConfiguration;
std::shared_ptr<EndpointProviderT> m_endpointProvider{};
std::shared_ptr<ServiceAuthSchemeResolverT> m_authSchemeResolver{};
Aws::UnorderedMap<Aws::String, AuthSchemesVariantT> m_authSchemes{};
Expand Down
34 changes: 30 additions & 4 deletions src/aws-cpp-sdk-core/include/smithy/client/AwsSmithyClientBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,31 @@ namespace client
{
private:
const char* ALLOC_TAG{"AwsSmithyClientBase"};


void deepCopyClientConfiguration(const AwsSmithyClientBase& target)
{
//first create copy from target
m_clientConfig = Aws::MakeShared<Aws::Client::ClientConfiguration>(target.m_serviceName.c_str(), *target.m_clientConfig);

//then reinitialize appropriate fields unconditionally
assert(m_clientConfig->configFactories.retryStrategyCreateFn);
m_clientConfig->retryStrategy = m_clientConfig->configFactories.retryStrategyCreateFn();

assert(m_clientConfig->configFactories.executorCreateFn);
m_clientConfig->executor = m_clientConfig->configFactories.executorCreateFn();

assert(m_clientConfig->configFactories.writeRateLimiterCreateFn);
m_clientConfig->writeRateLimiter = m_clientConfig->configFactories.writeRateLimiterCreateFn();

assert(m_clientConfig->configFactories.readRateLimiterCreateFn);
m_clientConfig->readRateLimiter = m_clientConfig->configFactories.readRateLimiterCreateFn();

assert(m_clientConfig->configFactories.telemetryProviderCreateFn);
m_clientConfig->telemetryProvider = m_clientConfig->configFactories.telemetryProviderCreateFn();

}

public:
using HttpRequest = Aws::Http::HttpRequest;
using HttpResponse = Aws::Http::HttpResponse;
Expand Down Expand Up @@ -128,22 +153,23 @@ namespace client
{
if (this != &target)
{
m_clientConfig = target.m_clientConfig;
deepCopyClientConfiguration(target);
m_serviceName = target.m_serviceName;
m_userAgent = target.m_userAgent;
m_httpClient = Aws::Http::CreateHttpClient(*target.m_clientConfig);
m_interceptors = {Aws::MakeShared<ChecksumInterceptor>(ALLOC_TAG)};
m_userAgent = Aws::Client::ComputeUserAgentString(m_clientConfig.get());
}
return *this;
}

AwsSmithyClientBase(const AwsSmithyClientBase& target):
m_clientConfig{target.m_clientConfig},
m_serviceName{target.m_serviceName},
m_userAgent{target.m_userAgent},
m_httpClient{Aws::Http::CreateHttpClient(*target.m_clientConfig)}
m_httpClient{Aws::Http::CreateHttpClient(*target.m_clientConfig)},
m_interceptors{Aws::MakeShared<ChecksumInterceptor>(ALLOC_TAG)}
{
m_interceptors = {Aws::MakeShared<ChecksumInterceptor>(ALLOC_TAG)};
deepCopyClientConfiguration(target);
}

AwsSmithyClientBase(AwsSmithyClientBase&& target) = default;
Expand Down

0 comments on commit b7441f0

Please sign in to comment.