-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Swap dynamo client to use a smithy base class #3091
Merged
+1,637
−2,150
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,645 changes: 540 additions & 2,105 deletions
2,645
generated/src/aws-cpp-sdk-dynamodb/source/DynamoDBClient.cpp
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/aws-cpp-sdk-core/include/smithy/client/serializer/JsonOutcomeSerializer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
#include <aws/core/AmazonWebServiceResult.h> | ||
#include <aws/core/client/AWSError.h> | ||
#include <aws/core/utils/Outcome.h> | ||
#include <aws/core/utils/json/JsonSerializer.h> | ||
#include <smithy/tracing/TracingUtils.h> | ||
#include <smithy/tracing/TelemetryProvider.h> | ||
|
||
namespace smithy | ||
{ | ||
namespace client | ||
{ | ||
using TracingUtils = components::tracing::TracingUtils; | ||
using CoreErrors = Aws::Client::CoreErrors; | ||
using AWSError = Aws::Client::AWSError<CoreErrors>; | ||
using JsonValue = Aws::Utils::Json::JsonValue; | ||
using HttpResponseOutcome = Aws::Utils::Outcome<std::shared_ptr<Aws::Http::HttpResponse>, AWSError>; | ||
using JsonOutcome = Aws::Utils::Outcome<Aws::AmazonWebServiceResult<JsonValue>, AWSError>; | ||
using TelemetryProvider = components::tracing::TelemetryProvider; | ||
|
||
class JsonOutcomeSerializer | ||
{ | ||
public: | ||
explicit JsonOutcomeSerializer(const std::shared_ptr<TelemetryProvider>& telemetryProvider) | ||
: m_telemetryProvider(telemetryProvider) | ||
{ | ||
} | ||
|
||
JsonOutcomeSerializer(const JsonOutcomeSerializer& other) = delete; | ||
JsonOutcomeSerializer(JsonOutcomeSerializer&& other) noexcept = default; | ||
JsonOutcomeSerializer& operator=(const JsonOutcomeSerializer& other) = delete; | ||
JsonOutcomeSerializer& operator=(JsonOutcomeSerializer&& other) noexcept = default; | ||
virtual ~JsonOutcomeSerializer() = default; | ||
|
||
JsonOutcome Deserialize(HttpResponseOutcome&& httpOutcome, | ||
const Aws::String& serviceName, | ||
const Aws::String& requestName) const | ||
{ | ||
if (!httpOutcome.IsSuccess()) | ||
{ | ||
return TracingUtils::MakeCallWithTiming<JsonOutcome>( | ||
[&]() -> JsonOutcome { | ||
return JsonOutcome{std::move(httpOutcome)}; | ||
}, | ||
TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, | ||
*m_telemetryProvider->getMeter(serviceName, {}), | ||
{{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, | ||
{TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); | ||
} | ||
|
||
if (httpOutcome.GetResult()->GetResponseBody().good() && | ||
httpOutcome.GetResult()->GetResponseBody().tellp() > 0) | ||
{ | ||
JsonValue jsonValue(httpOutcome.GetResult()->GetResponseBody()); | ||
if (!jsonValue.WasParseSuccessful()) { | ||
return TracingUtils::MakeCallWithTiming<JsonOutcome>( | ||
[&]() -> JsonOutcome { | ||
return JsonOutcome{AWSError(CoreErrors::UNKNOWN, | ||
"Json Parser Error", | ||
jsonValue.GetErrorMessage(), | ||
false)}; | ||
}, | ||
TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, | ||
*m_telemetryProvider->getMeter(serviceName, {}), | ||
{{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, | ||
{TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); | ||
} | ||
|
||
return TracingUtils::MakeCallWithTiming<JsonOutcome>( | ||
[&]() -> JsonOutcome { | ||
return JsonOutcome{Aws::AmazonWebServiceResult<JsonValue>(std::move(jsonValue), | ||
httpOutcome.GetResult()->GetHeaders(), | ||
httpOutcome.GetResult()->GetResponseCode())}; | ||
}, | ||
TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, | ||
*m_telemetryProvider->getMeter(serviceName, {}), | ||
{{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, | ||
{TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); | ||
} | ||
|
||
return TracingUtils::MakeCallWithTiming<JsonOutcome>( | ||
[&]() -> JsonOutcome { | ||
return JsonOutcome{Aws::AmazonWebServiceResult<JsonValue>(JsonValue(), | ||
httpOutcome.GetResult()->GetHeaders())}; | ||
}, | ||
TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, | ||
*m_telemetryProvider->getMeter(serviceName, {}), | ||
{{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, | ||
{TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); | ||
} | ||
|
||
private: | ||
std::shared_ptr<TelemetryProvider> m_telemetryProvider; | ||
}; | ||
} // namespace client | ||
} // namespace smithy |
88 changes: 88 additions & 0 deletions
88
src/aws-cpp-sdk-core/include/smithy/client/serializer/XmlOutcomeSerializer.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/** | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0. | ||
*/ | ||
#pragma once | ||
#include <aws/core/AmazonWebServiceResult.h> | ||
#include <aws/core/client/AWSError.h> | ||
#include <aws/core/utils/Outcome.h> | ||
#include <aws/core/utils/xml/XmlSerializer.h> | ||
#include <smithy/tracing/TracingUtils.h> | ||
#include <smithy/tracing/TelemetryProvider.h> | ||
|
||
namespace smithy | ||
{ | ||
namespace client | ||
{ | ||
using TracingUtils = components::tracing::TracingUtils; | ||
using CoreErrors = Aws::Client::CoreErrors; | ||
using AWSError = Aws::Client::AWSError<CoreErrors>; | ||
using XmlDocument = Aws::Utils::Xml::XmlDocument; | ||
using HttpResponseOutcome = Aws::Utils::Outcome<std::shared_ptr<Aws::Http::HttpResponse>, AWSError>; | ||
using XmlServiceResult = Aws::AmazonWebServiceResult<XmlDocument>; | ||
using XmlOutcome = Aws::Utils::Outcome<XmlServiceResult, AWSError>; | ||
using TelemetryProvider = components::tracing::TelemetryProvider; | ||
|
||
class XmlOutcomeSerializer | ||
{ | ||
public: | ||
explicit XmlOutcomeSerializer(const std::shared_ptr<TelemetryProvider>& telemetryProvider) | ||
: m_telemetryProvider(telemetryProvider) | ||
{ | ||
} | ||
|
||
XmlOutcomeSerializer(const XmlOutcomeSerializer& other) = delete; | ||
XmlOutcomeSerializer(XmlOutcomeSerializer&& other) noexcept = default; | ||
XmlOutcomeSerializer& operator=(const XmlOutcomeSerializer& other) = delete; | ||
XmlOutcomeSerializer& operator=(XmlOutcomeSerializer&& other) noexcept = default; | ||
virtual ~XmlOutcomeSerializer() = default; | ||
|
||
|
||
XmlOutcome Deserialize(HttpResponseOutcome&& httpOutcome, | ||
const Aws::String& serviceName, | ||
const Aws::String& requestName) const | ||
{ | ||
if (!httpOutcome.IsSuccess()) | ||
{ | ||
return TracingUtils::MakeCallWithTiming<XmlOutcome>( | ||
[&]() -> XmlOutcome { | ||
return {std::move(httpOutcome)}; | ||
}, | ||
TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, | ||
*m_telemetryProvider->getMeter(serviceName, {}), | ||
{{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); | ||
} | ||
|
||
if (httpOutcome.GetResult()->GetResponseBody().good() && | ||
httpOutcome.GetResult()->GetResponseBody().tellp() > 0) | ||
{ | ||
return TracingUtils::MakeCallWithTiming<XmlOutcome>( | ||
[&]() -> XmlOutcome { | ||
XmlDocument xmlDoc = XmlDocument::CreateFromXmlStream(httpOutcome.GetResult()->GetResponseBody()); | ||
|
||
if (!xmlDoc.WasParseSuccessful()) | ||
{ | ||
AWS_LOGSTREAM_ERROR("XmlOutcomeSerializer", "Xml parsing for error failed with message " << xmlDoc.GetErrorMessage().c_str()); | ||
return AWSError(CoreErrors::UNKNOWN, | ||
"Xml Parse Error", | ||
xmlDoc.GetErrorMessage(), | ||
false); | ||
} | ||
|
||
return {XmlServiceResult(std::move(xmlDoc), | ||
httpOutcome.GetResult()->GetHeaders(), | ||
httpOutcome.GetResult()->GetResponseCode())}; | ||
}, | ||
TracingUtils::SMITHY_CLIENT_DESERIALIZATION_METRIC, | ||
*m_telemetryProvider->getMeter(serviceName, {}), | ||
{{TracingUtils::SMITHY_METHOD_DIMENSION, requestName}, {TracingUtils::SMITHY_SERVICE_DIMENSION, serviceName}}); | ||
} | ||
|
||
return {XmlServiceResult(XmlDocument(), httpOutcome.GetResult()->GetHeaders())}; | ||
} | ||
private: | ||
std::shared_ptr<TelemetryProvider> m_telemetryProvider; | ||
}; | ||
|
||
} // namespace client | ||
} // namespace smithy |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: do we do it in other places? should we hide this behind a helper returning a ref to this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i see its used below?
something like
constexpr char str[] = "foo";
wouldnt work here?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this actually leads to gcc errors about odr
we ran into other things like this, and just looking around, i think it boils down to "we cant have the deifnition in a header"