From 12ffbb8a83182d3e76eb3f386ba9b99546779bcd Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 01:27:59 -0400 Subject: [PATCH 1/5] Add MessageLite type to grpc's config --- include/grpcpp/impl/codegen/config_protobuf.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/grpcpp/impl/codegen/config_protobuf.h b/include/grpcpp/impl/codegen/config_protobuf.h index 8c2e9e67927..ce28f855529 100644 --- a/include/grpcpp/impl/codegen/config_protobuf.h +++ b/include/grpcpp/impl/codegen/config_protobuf.h @@ -30,9 +30,11 @@ #ifdef GRPC_USE_PROTO_LITE #include #define GRPC_CUSTOM_MESSAGE ::google::protobuf::MessageLite +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite #else #include #define GRPC_CUSTOM_MESSAGE ::google::protobuf::Message +#define GRPC_CUSTOM_MESSAGELITE ::google::protobuf::MessageLite #endif #endif @@ -76,6 +78,7 @@ namespace grpc { namespace protobuf { typedef GRPC_CUSTOM_MESSAGE Message; +typedef GRPC_CUSTOM_MESSAGE MessageLite; typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; From 51a228002973be6b20a0ca9f133a5d581d3685bc Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 01:29:47 -0400 Subject: [PATCH 2/5] Add MessageLite overloads to proto serialization --- include/grpcpp/impl/codegen/proto_utils.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/grpcpp/impl/codegen/proto_utils.h b/include/grpcpp/impl/codegen/proto_utils.h index d9db6de05c0..9d3fcee0c98 100644 --- a/include/grpcpp/impl/codegen/proto_utils.h +++ b/include/grpcpp/impl/codegen/proto_utils.h @@ -42,7 +42,7 @@ extern CoreCodegenInterface* g_core_codegen_interface; // ProtoBufferWriter must be a subclass of ::protobuf::io::ZeroCopyOutputStream. template -Status GenericSerialize(const grpc::protobuf::Message& msg, ByteBuffer* bb, +Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, bool* own_buffer) { static_assert(std::is_base_of::value, @@ -68,7 +68,7 @@ Status GenericSerialize(const grpc::protobuf::Message& msg, ByteBuffer* bb, // BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream. template -Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) { +Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { static_assert(std::is_base_of::value, "ProtoBufferReader must be a subclass of " @@ -103,14 +103,14 @@ Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) { // be found in include/grpcpp/impl/codegen/serialization_traits.h. template class SerializationTraits::value>::type> { + grpc::protobuf::MessageLite, T>::value>::type> { public: - static Status Serialize(const grpc::protobuf::Message& msg, ByteBuffer* bb, + static Status Serialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, bool* own_buffer) { return GenericSerialize(msg, bb, own_buffer); } - static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::Message* msg) { + static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { return GenericDeserialize(buffer, msg); } }; From 3ec0967c1ef11c8b159b7cd7993846c050686b9d Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 01:52:36 -0400 Subject: [PATCH 3/5] Fix typo for using MessageLite --- include/grpcpp/impl/codegen/config_protobuf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpcpp/impl/codegen/config_protobuf.h b/include/grpcpp/impl/codegen/config_protobuf.h index ce28f855529..3c9ab3442af 100644 --- a/include/grpcpp/impl/codegen/config_protobuf.h +++ b/include/grpcpp/impl/codegen/config_protobuf.h @@ -78,7 +78,7 @@ namespace grpc { namespace protobuf { typedef GRPC_CUSTOM_MESSAGE Message; -typedef GRPC_CUSTOM_MESSAGE MessageLite; +typedef GRPC_CUSTOM_MESSAGELITE MessageLite; typedef GRPC_CUSTOM_PROTOBUF_INT64 int64; typedef GRPC_CUSTOM_DESCRIPTOR Descriptor; From cd0e02ae1c66c308debbea7476a0e40fedbaf5fd Mon Sep 17 00:00:00 2001 From: kwasimensah Date: Tue, 21 May 2019 02:29:00 -0400 Subject: [PATCH 5/5] Fixing formatting --- include/grpcpp/impl/codegen/proto_utils.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/grpcpp/impl/codegen/proto_utils.h b/include/grpcpp/impl/codegen/proto_utils.h index 9d3fcee0c98..f9a7d3c0b34 100644 --- a/include/grpcpp/impl/codegen/proto_utils.h +++ b/include/grpcpp/impl/codegen/proto_utils.h @@ -68,7 +68,8 @@ Status GenericSerialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, // BufferReader must be a subclass of ::protobuf::io::ZeroCopyInputStream. template -Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { +Status GenericDeserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { static_assert(std::is_base_of::value, "ProtoBufferReader must be a subclass of " @@ -102,15 +103,17 @@ Status GenericDeserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) // objects and grpc_byte_buffers. More information about SerializationTraits can // be found in include/grpcpp/impl/codegen/serialization_traits.h. template -class SerializationTraits::value>::type> { +class SerializationTraits< + T, typename std::enable_if< + std::is_base_of::value>::type> { public: - static Status Serialize(const grpc::protobuf::MessageLite& msg, ByteBuffer* bb, - bool* own_buffer) { + static Status Serialize(const grpc::protobuf::MessageLite& msg, + ByteBuffer* bb, bool* own_buffer) { return GenericSerialize(msg, bb, own_buffer); } - static Status Deserialize(ByteBuffer* buffer, grpc::protobuf::MessageLite* msg) { + static Status Deserialize(ByteBuffer* buffer, + grpc::protobuf::MessageLite* msg) { return GenericDeserialize(buffer, msg); } };