@@ -60,55 +60,78 @@ namespace client
60
60
m_authSchemes(authSchemes),
61
61
m_serializer(Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider))
62
62
{
63
- m_serviceName = ServiceNameT;
64
63
initClient ();
65
64
}
66
65
67
- AwsSmithyClientT (const AwsSmithyClientT& other):
68
- AwsSmithyClientBase (other,
69
- Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
70
- ServiceNameT,
71
- other.m_serviceUserAgentName,
72
- Aws::Http::CreateHttpClient (other.m_clientConfiguration),
73
- Aws::MakeShared<ErrorMarshallerT>(ServiceNameT)),
74
- m_clientConfiguration{*static_cast <ServiceClientConfigurationT*>(m_clientConfig.get ())},
75
- m_endpointProvider{other.m_endpointProvider },
76
- m_authSchemeResolver{Aws::MakeShared<ServiceAuthSchemeResolverT>(ServiceNameT)},
77
- m_authSchemes{other.m_authSchemes },
78
- m_serializer{Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider )}
66
+ AwsSmithyClientT (const AwsSmithyClientT& other)
67
+ : AwsSmithyClientBase(other,
68
+ Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration),
69
+ Aws::Http::CreateHttpClient (other.m_clientConfiguration),
70
+ Aws::MakeShared<ErrorMarshallerT>(ServiceNameT)),
71
+ m_clientConfiguration(*static_cast <ServiceClientConfigurationT*>(m_clientConfig.get()))
79
72
{
80
- initClient ();
73
+ m_endpointProvider = other.m_endpointProvider ; /* shallow copy */
74
+ m_authSchemeResolver = other.m_authSchemeResolver ; /* shallow copy */
75
+ m_authSchemes = other.m_authSchemes ;
76
+ m_serializer = Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider );
77
+ initClient ();
81
78
}
82
79
83
80
AwsSmithyClientT& operator =(const AwsSmithyClientT& other)
84
81
{
85
82
if (this != &other)
86
83
{
87
- AwsSmithyClientBase::deepCopy (Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, other.m_clientConfiguration ),
88
- ServiceNameT ,
89
- Aws::Http::CreateHttpClient (other. m_clientConfiguration ),
84
+ m_clientConfiguration = other.m_clientConfiguration ;
85
+ AwsSmithyClientBase::baseCopyAssign (other ,
86
+ Aws::Http::CreateHttpClient (m_clientConfiguration),
90
87
Aws::MakeShared<ErrorMarshallerT>(ServiceNameT));
91
- m_clientConfiguration = * static_cast <ServiceClientConfigurationT*>(m_clientConfig. get ());
92
- m_endpointProvider = other.m_endpointProvider ;
93
- m_authSchemeResolver = Aws::MakeShared<ServiceAuthSchemeResolverT>(ServiceNameT);
88
+
89
+ m_endpointProvider = other.m_endpointProvider ; /* shallow copy */
90
+ m_authSchemeResolver = other. m_authSchemeResolver ; /* shallow copy */
94
91
m_authSchemes = other.m_authSchemes ;
95
92
m_serializer = Aws::MakeShared<SerializerT>(ServiceNameT, m_clientConfiguration.telemetryProvider );
96
- m_errorMarshaller = Aws::MakeShared<ErrorMarshallerT>(ServiceNameT);
97
93
initClient ();
98
94
}
99
95
return *this ;
100
96
}
101
97
102
- AwsSmithyClientT (AwsSmithyClientT&&) = default ;
98
+ AwsSmithyClientT (AwsSmithyClientT&& other) :
99
+ AwsSmithyClientBase (std::move(static_cast <AwsSmithyClientBase&&>(other)),
100
+ Aws::MakeUnique<ServiceClientConfigurationT>(ServiceNameT, std::move(other.m_clientConfiguration))),
101
+ m_clientConfiguration{*static_cast <ServiceClientConfigurationT*>(m_clientConfig.get ())},
102
+ m_endpointProvider (std::move(other.m_endpointProvider)),
103
+ m_authSchemeResolver (std::move(other.m_authSchemeResolver)),
104
+ m_authSchemes (std::move(other.m_authSchemes)),
105
+ m_serializer (std::move(other.m_serializer))
106
+ {
107
+ }
103
108
104
- AwsSmithyClientT& operator =(AwsSmithyClientT&&) = default ;
109
+ AwsSmithyClientT& operator =(AwsSmithyClientT&& other)
110
+ {
111
+ if (this != &other)
112
+ {
113
+ m_clientConfiguration = std::move (other.m_clientConfiguration );
114
+ AwsSmithyClientBase::baseMoveAssign (std::move (static_cast <AwsSmithyClientBase&&>(other)));
115
+
116
+ m_endpointProvider = std::move (other.m_endpointProvider );
117
+ m_authSchemeResolver = std::move (other.m_authSchemeResolver );
118
+ m_authSchemes = std::move (other.m_authSchemes );
119
+ m_serializer = std::move (other.m_serializer );
120
+ }
121
+ return *this ;
122
+ }
105
123
106
124
virtual ~AwsSmithyClientT () = default ;
107
125
108
126
protected:
109
127
void initClient () {
110
- m_endpointProvider->InitBuiltInParameters (m_clientConfiguration);
111
- m_authSchemeResolver->Init (m_clientConfiguration);
128
+ if (m_endpointProvider && m_authSchemeResolver) {
129
+ m_endpointProvider->InitBuiltInParameters (m_clientConfiguration);
130
+ m_authSchemeResolver->Init (m_clientConfiguration);
131
+ } else {
132
+ AWS_LOGSTREAM_FATAL (ServiceNameT, " Unable to init client: endpoint provider=" << m_endpointProvider
133
+ << " or " << " authSchemeResolver=" << m_authSchemeResolver << " are null!" );
134
+ }
112
135
}
113
136
114
137
inline const char * GetServiceClientName () const override { return m_serviceName.c_str (); }
@@ -226,7 +249,7 @@ namespace client
226
249
const Aws::Http::URI& uri = endpoint.GetURI ();
227
250
auto signerRegionOverride = region;
228
251
auto signerServiceNameOverride = serviceName;
229
- // signer name is needed for some identity resolvers
252
+ // signer name is needed for some identity resolvers
230
253
if (endpoint.GetAttributes ()) {
231
254
if (endpoint.GetAttributes ()->authScheme .GetSigningRegion ()) {
232
255
signerRegionOverride = endpoint.GetAttributes ()->authScheme .GetSigningRegion ()->c_str ();
@@ -242,6 +265,10 @@ namespace client
242
265
}
243
266
244
267
protected:
268
+ /* Service client specific config, the actual object is stored in AwsSmithyClientBase by pointer
269
+ * In order to avoid config object duplication, smithy template client access it by a reference.
270
+ * So that base client has it by base config pointer, child smithy client has it by child config reference.
271
+ */
245
272
ServiceClientConfigurationT& m_clientConfiguration;
246
273
std::shared_ptr<EndpointProviderT> m_endpointProvider{};
247
274
std::shared_ptr<ServiceAuthSchemeResolverT> m_authSchemeResolver{};
0 commit comments