-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add schema-serde streaming JSON/XML deserializers, ec2Query, Codec, and ClientProtocol #3910
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
Open
pulimsr
wants to merge
1
commit into
main
Choose a base branch
from
schema-serde
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
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 hidden or 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,6 @@ | ||
| { | ||
| "type": "feature", | ||
| "category": "aws-cpp-sdk-core", | ||
| "contributor": "pulimsr", | ||
| "description": "Add schema-serde buffer-based JSON/XML deserializers, Query serializer (awsQuery/ec2Query), and Codec/ClientProtocol" | ||
| } |
This file contains hidden or 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
99 changes: 99 additions & 0 deletions
99
src/aws-cpp-sdk-core/include/smithy/client/schema/ClientProtocol.h
This file contains hidden or 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,99 @@ | ||
| #pragma once | ||
|
|
||
| #include <aws/core/utils/memory/AWSMemory.h> | ||
| #include <aws/core/utils/memory/stl/AWSString.h> | ||
| #include <smithy/Smithy_EXPORTS.h> | ||
| #include <smithy/client/schema/Codec.h> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class Schema; | ||
| class SerializableStruct; | ||
| class ShapeDeserializer; | ||
|
|
||
| class SMITHY_API ClientProtocol { | ||
| public: | ||
| using SerializerOutcome = Codec::SerializerOutcome; | ||
|
|
||
| virtual ~ClientProtocol() = default; | ||
|
|
||
| virtual Aws::String GetProtocolId() const = 0; | ||
| virtual Aws::String GetContentType() const = 0; | ||
| virtual SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const = 0; | ||
| virtual Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const = 0; | ||
| }; | ||
|
|
||
| class SMITHY_API RestJsonProtocol final : public ClientProtocol { | ||
| public: | ||
| Aws::String GetProtocolId() const override; | ||
| Aws::String GetContentType() const override; | ||
| SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const override; | ||
|
|
||
| private: | ||
| JsonCodec m_codec; | ||
| }; | ||
|
|
||
| class SMITHY_API AwsJson10Protocol final : public ClientProtocol { | ||
| public: | ||
| Aws::String GetProtocolId() const override; | ||
| Aws::String GetContentType() const override; | ||
| SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const override; | ||
|
|
||
| private: | ||
| JsonCodec m_codec; | ||
| }; | ||
|
|
||
| class SMITHY_API AwsJson11Protocol final : public ClientProtocol { | ||
| public: | ||
| Aws::String GetProtocolId() const override; | ||
| Aws::String GetContentType() const override; | ||
| SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const override; | ||
|
|
||
| private: | ||
| JsonCodec m_codec; | ||
| }; | ||
|
|
||
| class SMITHY_API RpcV2CborProtocol final : public ClientProtocol { | ||
| public: | ||
| Aws::String GetProtocolId() const override; | ||
| Aws::String GetContentType() const override; | ||
| SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const override; | ||
|
|
||
| private: | ||
| CborCodec m_codec; | ||
| }; | ||
|
|
||
| class SMITHY_API RestXmlProtocol final : public ClientProtocol { | ||
| public: | ||
| Aws::String GetProtocolId() const override; | ||
| Aws::String GetContentType() const override; | ||
| SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const override; | ||
|
|
||
| private: | ||
| XmlCodec m_codec; | ||
| }; | ||
|
|
||
| class SMITHY_API AwsQueryProtocol final : public ClientProtocol { | ||
| public: | ||
| Aws::String GetProtocolId() const override; | ||
| Aws::String GetContentType() const override; | ||
| SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const override; | ||
| }; | ||
|
|
||
| class SMITHY_API Ec2QueryProtocol final : public ClientProtocol { | ||
| public: | ||
| Aws::String GetProtocolId() const override; | ||
| Aws::String GetContentType() const override; | ||
| SerializerOutcome SerializeInput(const Schema& schema, const SerializableStruct& input) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateOutputDeserializer(const unsigned char* data, size_t length) const override; | ||
| }; | ||
|
|
||
| } | ||
| } |
This file contains hidden or 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,47 @@ | ||
| #pragma once | ||
|
|
||
| #include <aws/core/client/AWSError.h> | ||
| #include <aws/core/client/CoreErrors.h> | ||
| #include <aws/core/utils/Outcome.h> | ||
| #include <aws/core/utils/memory/AWSMemory.h> | ||
| #include <aws/core/utils/memory/stl/AWSString.h> | ||
| #include <smithy/Smithy_EXPORTS.h> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class Schema; | ||
| class SerializableStruct; | ||
| class ShapeDeserializer; | ||
|
|
||
| class SMITHY_API Codec { | ||
| public: | ||
| using SerializerOutcome = Aws::Utils::Outcome<Aws::String, Aws::Client::AWSError<Aws::Client::CoreErrors>>; | ||
|
|
||
| virtual ~Codec() = default; | ||
|
|
||
| virtual SerializerOutcome Serialize(const Schema& schema, const SerializableStruct& shape) const = 0; | ||
|
|
||
| virtual Aws::UniquePtr<ShapeDeserializer> CreateDeserializer(const unsigned char* data, size_t length) const = 0; | ||
| }; | ||
|
|
||
| class SMITHY_API JsonCodec final : public Codec { | ||
| public: | ||
| SerializerOutcome Serialize(const Schema& schema, const SerializableStruct& shape) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateDeserializer(const unsigned char* data, size_t length) const override; | ||
| }; | ||
|
|
||
| class SMITHY_API XmlCodec final : public Codec { | ||
| public: | ||
| SerializerOutcome Serialize(const Schema& schema, const SerializableStruct& shape) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateDeserializer(const unsigned char* data, size_t length) const override; | ||
| }; | ||
|
|
||
| class SMITHY_API CborCodec final : public Codec { | ||
| public: | ||
| SerializerOutcome Serialize(const Schema& schema, const SerializableStruct& shape) const override; | ||
| Aws::UniquePtr<ShapeDeserializer> CreateDeserializer(const unsigned char* data, size_t length) const override; | ||
| }; | ||
|
|
||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
src/aws-cpp-sdk-core/include/smithy/client/schema/JsonShapeDeserializer.h
This file contains hidden or 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,37 @@ | ||
| #pragma once | ||
|
|
||
| #include <aws/core/utils/memory/AWSMemory.h> | ||
| #include <smithy/Smithy_EXPORTS.h> | ||
| #include <smithy/client/schema/ShapeDeserializer.h> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class SMITHY_API JsonShapeDeserializer final : public ShapeDeserializer { | ||
| public: | ||
| JsonShapeDeserializer(const unsigned char* data, size_t length); | ||
| ~JsonShapeDeserializer(); | ||
|
|
||
| void ReadStruct(const Schema& schema, const StructMemberConsumer& consumer) override; | ||
| void ReadList(const Schema& schema, const ListElementConsumer& consumer) override; | ||
| void ReadMap(const Schema& schema, const MapEntryConsumer& consumer) override; | ||
|
|
||
| Aws::Crt::Optional<bool> ReadBoolean(const Schema& schema) override; | ||
| Aws::Crt::Optional<int> ReadInteger(const Schema& schema) override; | ||
| Aws::Crt::Optional<int64_t> ReadLong(const Schema& schema) override; | ||
| Aws::Crt::Optional<float> ReadFloat(const Schema& schema) override; | ||
| Aws::Crt::Optional<double> ReadDouble(const Schema& schema) override; | ||
| Aws::Crt::Optional<Aws::String> ReadString(const Schema& schema) override; | ||
| Aws::Crt::Optional<Aws::Utils::DateTime> ReadTimestamp(const Schema& schema) override; | ||
| Aws::Crt::Optional<Aws::Utils::ByteBuffer> ReadBlob(const Schema& schema) override; | ||
| Aws::Crt::Optional<int> ReadEnum(const Schema& schema) override; | ||
|
|
||
| bool IsNull() override; | ||
|
|
||
| private: | ||
| class Impl; | ||
| Aws::UniquePtr<Impl> m_impl; | ||
| }; | ||
|
|
||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
src/aws-cpp-sdk-core/include/smithy/client/schema/QueryShapeSerializer.h
This file contains hidden or 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,50 @@ | ||
| /** | ||
| * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
| * SPDX-License-Identifier: Apache-2.0. | ||
| */ | ||
| #pragma once | ||
|
|
||
| #include <aws/core/client/AWSError.h> | ||
| #include <aws/core/utils/memory/AWSMemory.h> | ||
| #include <smithy/Smithy_EXPORTS.h> | ||
| #include <smithy/client/schema/ShapeSerializer.h> | ||
|
|
||
| #include <functional> | ||
|
|
||
| namespace smithy { | ||
| namespace schema { | ||
|
|
||
| class SMITHY_API QueryShapeSerializer final : public ShapeSerializer { | ||
| public: | ||
| using SerializerOutcome = Aws::Utils::Outcome<Aws::String, Aws::Client::AWSError<Aws::Client::CoreErrors>>; | ||
|
|
||
| enum class Flavor { AwsQuery, Ec2Query }; | ||
|
|
||
| QueryShapeSerializer(); | ||
| explicit QueryShapeSerializer(Flavor flavor); | ||
| ~QueryShapeSerializer(); | ||
|
|
||
| void WriteStruct(const Schema& schema, const SerializableStruct& value) override; | ||
| void WriteList(const Schema& schema, size_t size, const std::function<void(ShapeSerializer&)>& consumer) override; | ||
| void WriteMap(const Schema& schema, size_t size, const std::function<void(MapSerializer&)>& consumer) override; | ||
|
|
||
| void WriteBoolean(const Schema& schema, bool value) override; | ||
| void WriteInteger(const Schema& schema, int value) override; | ||
| void WriteLong(const Schema& schema, int64_t value) override; | ||
| void WriteFloat(const Schema& schema, float value) override; | ||
| void WriteDouble(const Schema& schema, double value) override; | ||
| void WriteString(const Schema& schema, const Aws::String& value) override; | ||
| void WriteTimestamp(const Schema& schema, const Aws::Utils::DateTime& value) override; | ||
| void WriteBlob(const Schema& schema, const Aws::Utils::ByteBuffer& value) override; | ||
| void WriteEnum(const Schema& schema, int value) override; | ||
| void WriteNull(const Schema& schema) override; | ||
|
|
||
| SerializerOutcome GetPayload(); | ||
|
|
||
| private: | ||
| class Impl; | ||
| Aws::UniquePtr<Impl> m_impl; | ||
| }; | ||
|
|
||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
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.
summarizing from offline:
ok i think
CreateDeserializeris where where we have the disconnect and where it will come together for us with "how do we actually create a object T". so looking at the smithy java codec. we're actually borrowing a little bit more than we need. and we can actually walk this back.so
Serializelooks good, lets park that lets only talk about deserializein the java impl the have one called
deserializeShapethat is closer to our needs and answers the second question which is "how do we construct T given a stream of characters".javas looks like
ours should end up looking like
this is so that during coden class would implement those struct member consumers to construct self