From 726561ed062c6bb3635b48044bc5bb00de31e97e Mon Sep 17 00:00:00 2001 From: vjpai Date: Wed, 22 Jun 2016 11:14:24 -0700 Subject: [PATCH 01/31] Initial definition of flow-controlled unary type along with code generation for this type --- BUILD | 5 + Makefile | 6 ++ build.yaml | 2 + include/grpc++/impl/codegen/fc_unary.h | 97 +++++++++++++++++++ .../grpc++/impl/codegen/method_handler_impl.h | 35 +++++++ include/grpc++/impl/codegen/rpc_method.h | 3 +- include/grpc++/support/fc_unary.h | 39 ++++++++ src/compiler/cpp_generator.cc | 44 +++++++++ src/cpp/server/server.cc | 1 + tools/doxygen/Doxyfile.c++ | 2 + tools/doxygen/Doxyfile.c++.internal | 2 + tools/run_tests/sources_and_headers.json | 4 + vsprojects/vcxproj/grpc++/grpc++.vcxproj | 2 + .../vcxproj/grpc++/grpc++.vcxproj.filters | 6 ++ .../grpc++_reflection.vcxproj | 1 + .../grpc++_reflection.vcxproj.filters | 3 + .../grpc++_test_util/grpc++_test_util.vcxproj | 1 + .../grpc++_test_util.vcxproj.filters | 3 + .../grpc++_unsecure/grpc++_unsecure.vcxproj | 2 + .../grpc++_unsecure.vcxproj.filters | 6 ++ .../codegen_test_full.vcxproj | 1 + .../codegen_test_full.vcxproj.filters | 3 + .../codegen_test_minimal.vcxproj | 1 + .../codegen_test_minimal.vcxproj.filters | 3 + 24 files changed, 271 insertions(+), 1 deletion(-) create mode 100644 include/grpc++/impl/codegen/fc_unary.h create mode 100644 include/grpc++/support/fc_unary.h diff --git a/BUILD b/BUILD index ac0eb8e403d..df77fea040e 100644 --- a/BUILD +++ b/BUILD @@ -1301,6 +1301,7 @@ cc_library( "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", + "include/grpc++/support/fc_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -1320,6 +1321,7 @@ cc_library( "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", + "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -1399,6 +1401,7 @@ cc_library( "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", + "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -1527,6 +1530,7 @@ cc_library( "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", + "include/grpc++/support/fc_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -1546,6 +1550,7 @@ cc_library( "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", + "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", diff --git a/Makefile b/Makefile index 9be3e5784cc..05da53233ed 100644 --- a/Makefile +++ b/Makefile @@ -3530,6 +3530,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ + include/grpc++/support/fc_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -3549,6 +3550,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ + include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -3675,6 +3677,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ + include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -3853,6 +3856,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ + include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -4017,6 +4021,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ + include/grpc++/support/fc_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -4036,6 +4041,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ + include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ diff --git a/build.yaml b/build.yaml index 1f06e20cf9b..27b6a1b0585 100644 --- a/build.yaml +++ b/build.yaml @@ -676,6 +676,7 @@ filegroups: - include/grpc++/support/byte_buffer.h - include/grpc++/support/channel_arguments.h - include/grpc++/support/config.h + - include/grpc++/support/fc_unary.h - include/grpc++/support/slice.h - include/grpc++/support/status.h - include/grpc++/support/status_code_enum.h @@ -733,6 +734,7 @@ filegroups: - include/grpc++/impl/codegen/config.h - include/grpc++/impl/codegen/core_codegen_interface.h - include/grpc++/impl/codegen/create_auth_context.h + - include/grpc++/impl/codegen/fc_unary.h - include/grpc++/impl/codegen/grpc_library.h - include/grpc++/impl/codegen/method_handler_impl.h - include/grpc++/impl/codegen/rpc_method.h diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h new file mode 100644 index 00000000000..abb204939db --- /dev/null +++ b/include/grpc++/impl/codegen/fc_unary.h @@ -0,0 +1,97 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_IMPL_CODEGEN_FC_UNARY_H +#define GRPCXX_IMPL_CODEGEN_FC_UNARY_H + +#include +#include +#include + +namespace grpc { + +/// A class to represent a flow-controlled unary call. This is something +/// of a hybrid between conventional unary and streaming. This is invoked +/// through a unary call on the client side, but the server responds to it +/// as though it were a single-ping-pong streaming call. The server can use +/// the \a Size method to determine an upper-bound on the size of the message +/// A key difference relative to streaming: an FCUnary must have exactly 1 Read +/// and exactly 1 Write, in that order, to function correctly. +/// Otherwise, the RPC is in error +template + class FCUnary GRPC_FINAL { + public: + FCUnary(Call* call, ServerContext* ctx, int max_message_size): call_(call), ctx_(ctx), max_msg_size_(max_message_size), read_done_(false), write_done_(false) {} + ~FCUnary() {} + uint32_t Size() {return max_msg_size_;} + bool Read(RequestType *request) { + if (read_done_) { + return false; + } + read_done_ = true; + CallOpSet> ops; + ops.RecvMessage(request); + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops) && ops.got_message; + } + bool Write(const ResponseType& response) {return Write(response, WriteOptions());} + bool Write(const ResponseType& response, const WriteOptions& options) { + if (write_done_ || !read_done_) { + return false; + } + write_done_ = true; + CallOpSet ops; + if (!ops.SendMessage(response, options).ok()) { + return false; + } + if (!ctx_->sent_initial_metadata_) { + ops.SendInitialMetadata(ctx_->initial_metadata_, + ctx_->initial_metadata_flags()); + ctx_->sent_initial_metadata_ = true; + } else { + return false; + } + call_->PerformOps(&ops); + return call_->cq()->Pluck(&ops); + } + private: + Call* const call_; + ServerContext* const ctx_; + const int max_msg_size_; + bool read_done_; + bool write_done_; +}; + +} // namespace grpc + +#endif // GRPCXX_IMPL_CODEGEN_FC_UNARY_H diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 21ac6c4fb55..ecf481ebb6c 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -35,6 +35,7 @@ #define GRPCXX_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H #include +#include #include #include @@ -190,6 +191,40 @@ class BidiStreamingHandler : public MethodHandler { ServiceType* service_; }; +// A wrapper class of an application provided rpc method handler +// specifically to apply to the flow-controlled implementation of a unary +// method +template +class FCUnaryMethodHandler : public MethodHandler { + public: + FCUnaryMethodHandler(std::function*)> + func, ServiceType* service) + : func_(func), service_(service) {} + + void RunHandler(const HandlerParameter& param) GRPC_FINAL { + FCUnary fc_unary(param.call, + param.server_context, + param.max_message_size); + Status status = func_(service_, param.server_context, &fc_unary); + if (!param.server_context->sent_initial_metadata_) { + // means that the write never happened, which is bad + } else { + CallOpSet ops; + ops.ServerSendStatus(param.server_context->trailing_metadata_, status); + param.call->PerformOps(&ops); + param.call->cq()->Pluck(&ops); + } + } + private: + // Application provided rpc handler function. + std::function*)> + func_; + // The class the above handler function lives in. + ServiceType* service_; +}; + // Handle unknown method by returning UNIMPLEMENTED error. class UnknownMethodHandler : public MethodHandler { public: diff --git a/include/grpc++/impl/codegen/rpc_method.h b/include/grpc++/impl/codegen/rpc_method.h index 39cb4f75dfe..53bee3727ef 100644 --- a/include/grpc++/impl/codegen/rpc_method.h +++ b/include/grpc++/impl/codegen/rpc_method.h @@ -46,7 +46,8 @@ class RpcMethod { NORMAL_RPC = 0, CLIENT_STREAMING, // request streaming SERVER_STREAMING, // response streaming - BIDI_STREAMING + BIDI_STREAMING, + FC_UNARY // flow-controlled unary call }; RpcMethod(const char* name, RpcType type) diff --git a/include/grpc++/support/fc_unary.h b/include/grpc++/support/fc_unary.h new file mode 100644 index 00000000000..7e7dea8feb2 --- /dev/null +++ b/include/grpc++/support/fc_unary.h @@ -0,0 +1,39 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPCXX_SUPPORT_FC_UNARY_H +#define GRPCXX_SUPPORT_FC_UNARY_H + +#include + +#endif // GRPCXX_SUPPORT_FC_UNARY_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 2288ba41636..e5db84ab117 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -606,6 +606,50 @@ void PrintHeaderServerMethodAsync( printer->Print(*vars, "};\n"); } +void PrintHeaderServerMethodFCUnary( + Printer *printer, + const Method *method, + std::map *vars) { + (*vars)["Method"] = method->name(); + (*vars)["Request"] = method->input_type_name(); + (*vars)["Response"] = method->output_type_name(); + if (method->NoStreaming()) { + printer->Print(*vars, "template \n"); + printer->Print(*vars, + "class WithFCUnaryMethod_$Method$ : public BaseClass {\n"); + printer->Print( + " private:\n" + " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + printer->Print(" public:\n"); + printer->Indent(); + printer->Print(*vars, + "WithFCUnaryMethod_$Method$() {\n" + "}\n"); + printer->Print(*vars, + "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n" + " BaseClassMustBeDerivedFromService(this);\n" + "}\n"); + printer->Print( + *vars, + "// disable regular version of this method\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* context, const $Request$* request, " + "$Response$* response) GRPC_FINAL GRPC_OVERRIDE {\n" + " abort();\n" + " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" + "}\n"); + printer->Print( + *vars, + "// replace default version of this method with FCUnary\n" + "::grpc::Status $Method$(" + "::grpc::ServerContext* context, ::grpc::FCUnary<$Request$,$Response$>* streaming_unary)" + " GRPC_FINAL GRPC_OVERRIDE;\n"); + printer->Print("}\n"); + printer->Outdent(); + printer->Print(*vars, "};\n"); + } +} + void PrintHeaderServerMethodGeneric( Printer *printer, const Method *method, diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index fb4c68ebe49..68db9fb6dff 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -341,6 +341,7 @@ static grpc_server_register_method_payload_handling PayloadHandlingForMethod( return GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER; case RpcMethod::CLIENT_STREAMING: case RpcMethod::BIDI_STREAMING: + case RpcMethod::FC_UNARY: return GRPC_SRM_PAYLOAD_NONE; } GPR_UNREACHABLE_CODE(return GRPC_SRM_PAYLOAD_NONE;); diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 7f9d2df6f6c..ed46f8a2bec 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -800,6 +800,7 @@ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ +include/grpc++/support/fc_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -819,6 +820,7 @@ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ +include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index dcf1a4c8c40..005f4f2b3f2 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -800,6 +800,7 @@ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ +include/grpc++/support/fc_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -819,6 +820,7 @@ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ +include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 00018834af9..21bd776c6d5 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6555,6 +6555,7 @@ "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", + "include/grpc++/support/fc_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -6609,6 +6610,7 @@ "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", + "include/grpc++/support/fc_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -6666,6 +6668,7 @@ "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", + "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -6700,6 +6703,7 @@ "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", + "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index cb9e41ea22f..730e6c0c6c1 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -298,6 +298,7 @@ + @@ -317,6 +318,7 @@ + diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index a9051182b3c..c444cf0cb68 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -222,6 +222,9 @@ include\grpc++\support + + include\grpc++\support + include\grpc++\support @@ -279,6 +282,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj index 7c3e63b2084..e7f504fc2b6 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj @@ -163,6 +163,7 @@ + diff --git a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters index d9cd49cc306..edc8866420d 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters @@ -63,6 +63,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj index d0fca9ba65a..026952c1bd0 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj @@ -159,6 +159,7 @@ + diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters index cc98c604080..cc3fb70fa43 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters @@ -69,6 +69,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index 03be485b297..0b97b1ebc3a 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -298,6 +298,7 @@ + @@ -317,6 +318,7 @@ + diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index ba99bc53c8c..85cc8f7814d 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -207,6 +207,9 @@ include\grpc++\support + + include\grpc++\support + include\grpc++\support @@ -264,6 +267,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj index e608f7ed3a3..0e2b0d8adb3 100644 --- a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj @@ -172,6 +172,7 @@ + diff --git a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters index 8fc8f3901b3..098c89cdcc6 100644 --- a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters +++ b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters @@ -57,6 +57,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj index 3331c618473..d5133f72388 100644 --- a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj @@ -172,6 +172,7 @@ + diff --git a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters index a8ff1153177..e4e68de1856 100644 --- a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters +++ b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters @@ -60,6 +60,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen From ba6597f297b1cc1a8d91ca9154fee81c1639acdd Mon Sep 17 00:00:00 2001 From: vjpai Date: Wed, 22 Jun 2016 15:49:48 -0700 Subject: [PATCH 02/31] Actually generate code for FC Unary and make it work --- include/grpc++/impl/codegen/fc_unary.h | 1 + src/compiler/cpp_generator.cc | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h index abb204939db..c5e44ca0fdb 100644 --- a/include/grpc++/impl/codegen/fc_unary.h +++ b/include/grpc++/impl/codegen/fc_unary.h @@ -35,6 +35,7 @@ #define GRPCXX_IMPL_CODEGEN_FC_UNARY_H #include +#include #include #include diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index e5db84ab117..eadbb3be85c 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -128,6 +128,7 @@ grpc::string GetHeaderIncludes(File *file, static const char *headers_strs[] = { "grpc++/impl/codegen/async_stream.h", "grpc++/impl/codegen/async_unary_call.h", + "grpc++/impl/codegen/fc_unary.h", "grpc++/impl/codegen/proto_utils.h", "grpc++/impl/codegen/rpc_method.h", "grpc++/impl/codegen/service_type.h", @@ -642,9 +643,8 @@ void PrintHeaderServerMethodFCUnary( *vars, "// replace default version of this method with FCUnary\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, ::grpc::FCUnary<$Request$,$Response$>* streaming_unary)" + "::grpc::ServerContext* context, ::grpc::FCUnary< $Request$,$Response$>* streaming_unary)" " GRPC_FINAL GRPC_OVERRIDE;\n"); - printer->Print("}\n"); printer->Outdent(); printer->Print(*vars, "};\n"); } @@ -815,6 +815,12 @@ void PrintHeaderService(Printer *printer, PrintHeaderServerMethodGeneric(printer, service->method(i).get(), vars); } + // Server side - FC Unary + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["Idx"] = as_string(i); + PrintHeaderServerMethodFCUnary(printer, service->method(i).get(), vars); + } + printer->Outdent(); printer->Print("};\n"); printer->Print(service->GetTrailingComments().c_str()); @@ -917,6 +923,7 @@ grpc::string GetSourceIncludes(File *file, "grpc++/impl/codegen/async_unary_call.h", "grpc++/impl/codegen/channel_interface.h", "grpc++/impl/codegen/client_unary_call.h", + "grpc++/impl/codegen/fc_unary.h", "grpc++/impl/codegen/method_handler_impl.h", "grpc++/impl/codegen/rpc_service_method.h", "grpc++/impl/codegen/service_type.h", From 7142a91fc961fa6be7093134b13d7b00896e40f0 Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 10:16:00 -0700 Subject: [PATCH 03/31] Fix up service types and method handlers so that FC unary can work properly. --- include/grpc++/impl/codegen/rpc_method.h | 3 ++- include/grpc++/impl/codegen/rpc_service_method.h | 1 + include/grpc++/impl/codegen/service_type.h | 7 +++++++ src/compiler/cpp_generator.cc | 9 +++++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/grpc++/impl/codegen/rpc_method.h b/include/grpc++/impl/codegen/rpc_method.h index 53bee3727ef..728ba3e334d 100644 --- a/include/grpc++/impl/codegen/rpc_method.h +++ b/include/grpc++/impl/codegen/rpc_method.h @@ -61,11 +61,12 @@ class RpcMethod { const char* name() const { return name_; } RpcType method_type() const { return method_type_; } + void SetMethodType(RpcType type) { method_type_ = type; } void* channel_tag() const { return channel_tag_; } private: const char* const name_; - const RpcType method_type_; + RpcType method_type_; void* const channel_tag_; }; diff --git a/include/grpc++/impl/codegen/rpc_service_method.h b/include/grpc++/impl/codegen/rpc_service_method.h index 8b1f026c912..02da2a26177 100644 --- a/include/grpc++/impl/codegen/rpc_service_method.h +++ b/include/grpc++/impl/codegen/rpc_service_method.h @@ -82,6 +82,7 @@ class RpcServiceMethod : public RpcMethod { // if MethodHandler is nullptr, then this is an async method MethodHandler* handler() const { return handler_.get(); } void ResetHandler() { handler_.reset(); } + void SetHandler(MethodHandler *handler) { handler_.reset(handler); } private: void* server_tag_; diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h index c19dfc7d45f..c0eeace8a4b 100644 --- a/include/grpc++/impl/codegen/service_type.h +++ b/include/grpc++/impl/codegen/service_type.h @@ -147,6 +147,13 @@ class Service { methods_[index].reset(); } + void MarkMethodFCUnary(int index, MethodHandler* fc_unary_method) { + GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() && + "Cannot mark an async or generic method as FCUnary"); + methods_[index]->SetMethodType(::grpc::RpcMethod::FC_UNARY); + methods_[index]->SetHandler(fc_unary_method); + } + private: friend class Server; friend class ServerInterface; diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index eadbb3be85c..bbd476783cc 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -129,6 +129,7 @@ grpc::string GetHeaderIncludes(File *file, "grpc++/impl/codegen/async_stream.h", "grpc++/impl/codegen/async_unary_call.h", "grpc++/impl/codegen/fc_unary.h", + "grpc++/impl/codegen/method_handler_impl.h", "grpc++/impl/codegen/proto_utils.h", "grpc++/impl/codegen/rpc_method.h", "grpc++/impl/codegen/service_type.h", @@ -625,6 +626,11 @@ void PrintHeaderServerMethodFCUnary( printer->Indent(); printer->Print(*vars, "WithFCUnaryMethod_$Method$() {\n" + " ::grpc::Status (*fn)(::grpc::ServerContext*, ::grpc::FCUnary< $Request$,$Response$>*) = this->WithFCUnaryMethod_$Method$::$Method$;\n" + " ::grpc::Service::MarkMethodFCUnary($Idx$,\n" + " new ::grpc::FCUnaryMethodHandler(fn, this));\n" "}\n"); printer->Print(*vars, "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n" @@ -1138,6 +1144,9 @@ void PrintSourceService(Printer *printer, (*vars)["Idx"] = as_string(i); if (method->NoStreaming()) { (*vars)["StreamingType"] = "NORMAL_RPC"; + // NOTE: There is no reason to consider FC_UNARY as a separate + // category here since this part is setting up the client-side stub + // and this appears as a NORMAL_RPC from the client-side. } else if (method->ClientOnlyStreaming()) { (*vars)["StreamingType"] = "CLIENT_STREAMING"; } else if (method->ServerOnlyStreaming()) { From 34edfc3ad74442822100dd343072125f463b0ad5 Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 10:19:48 -0700 Subject: [PATCH 04/31] Switch name to fc_unary --- src/compiler/cpp_generator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index bbd476783cc..da89d433b12 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -649,7 +649,7 @@ void PrintHeaderServerMethodFCUnary( *vars, "// replace default version of this method with FCUnary\n" "::grpc::Status $Method$(" - "::grpc::ServerContext* context, ::grpc::FCUnary< $Request$,$Response$>* streaming_unary)" + "::grpc::ServerContext* context, ::grpc::FCUnary< $Request$,$Response$>* fc_unary)" " GRPC_FINAL GRPC_OVERRIDE;\n"); printer->Outdent(); printer->Print(*vars, "};\n"); From a12276932da60bab9a0feff0589965ec1f08e88f Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 13:18:19 -0700 Subject: [PATCH 05/31] Add some const --- include/grpc++/impl/codegen/call.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index fab85d15176..a9a5eb9f00f 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -656,10 +656,10 @@ class Call GRPC_FINAL { call_hook_->PerformOpsOnCall(ops, this); } - grpc_call* call() { return call_; } - CompletionQueue* cq() { return cq_; } + grpc_call* call() const { return call_; } + CompletionQueue* cq() const { return cq_; } - int max_message_size() { return max_message_size_; } + int max_message_size() const { return max_message_size_; } private: CallHook* call_hook_; From fcb98a578cb6b359e4fd26fb618578def4d8193d Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 13:18:50 -0700 Subject: [PATCH 06/31] Add NextMessageSize method to all readable streams as an upper-bound on the actual message size. Rename Size of FCUnary to NextMessageSize for consistency --- include/grpc++/impl/codegen/fc_unary.h | 10 +++++----- include/grpc++/impl/codegen/method_handler_impl.h | 3 +-- include/grpc++/impl/codegen/sync_stream.h | 11 +++++++++++ test/cpp/end2end/mock_test.cc | 3 +++ 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h index c5e44ca0fdb..abbdd42c785 100644 --- a/include/grpc++/impl/codegen/fc_unary.h +++ b/include/grpc++/impl/codegen/fc_unary.h @@ -45,16 +45,17 @@ namespace grpc { /// of a hybrid between conventional unary and streaming. This is invoked /// through a unary call on the client side, but the server responds to it /// as though it were a single-ping-pong streaming call. The server can use -/// the \a Size method to determine an upper-bound on the size of the message +/// the \a NextMessageSize method to determine an upper-bound on the size of +/// the message. /// A key difference relative to streaming: an FCUnary must have exactly 1 Read /// and exactly 1 Write, in that order, to function correctly. -/// Otherwise, the RPC is in error +/// Otherwise, the RPC is in error. template class FCUnary GRPC_FINAL { public: - FCUnary(Call* call, ServerContext* ctx, int max_message_size): call_(call), ctx_(ctx), max_msg_size_(max_message_size), read_done_(false), write_done_(false) {} + FCUnary(Call* call, ServerContext* ctx): call_(call), ctx_(ctx), read_done_(false), write_done_(false) {} ~FCUnary() {} - uint32_t Size() {return max_msg_size_;} + uint32_t NextMessageSize() {return call_->max_message_size();} bool Read(RequestType *request) { if (read_done_) { return false; @@ -88,7 +89,6 @@ template private: Call* const call_; ServerContext* const ctx_; - const int max_msg_size_; bool read_done_; bool write_done_; }; diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index ecf481ebb6c..2a14ef39776 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -204,8 +204,7 @@ class FCUnaryMethodHandler : public MethodHandler { void RunHandler(const HandlerParameter& param) GRPC_FINAL { FCUnary fc_unary(param.call, - param.server_context, - param.max_message_size); + param.server_context); Status status = func_(service_, param.server_context, &fc_unary); if (!param.server_context->sent_initial_metadata_) { // means that the write never happened, which is bad diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index e94ffe58422..eb76edd1401 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -70,6 +70,9 @@ class ReaderInterface { public: virtual ~ReaderInterface() {} + /// Upper bound on the next message size available for reading on this stream + virtual uint32_t NextMessageSize() = 0; + /// Blocking read a message and parse to \a msg. Returns \a true on success. /// /// \param[out] msg The read message. @@ -143,6 +146,8 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { cq_.Pluck(&ops); /// status ignored } + uint32_t NextMessageSize() GRPC_OVERRIDE {return call_.max_message_size();} + bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; if (!context_->initial_metadata_received_) { @@ -286,6 +291,8 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { cq_.Pluck(&ops); // status ignored } + uint32_t NextMessageSize() GRPC_OVERRIDE {return call_.max_message_size();} + bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; if (!context_->initial_metadata_received_) { @@ -345,6 +352,8 @@ class ServerReader GRPC_FINAL : public ReaderInterface { call_->cq()->Pluck(&ops); } + uint32_t NextMessageSize() GRPC_OVERRIDE {return call_->max_message_size();} + bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; ops.RecvMessage(msg); @@ -411,6 +420,8 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface, call_->cq()->Pluck(&ops); } + uint32_t NextMessageSize() GRPC_OVERRIDE {return call_->max_message_size();} + bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; ops.RecvMessage(msg); diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 0ace5d94183..744a7cd9eb9 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -31,6 +31,7 @@ * */ +#include #include #include @@ -63,6 +64,7 @@ class MockClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { public: void WaitForInitialMetadata() GRPC_OVERRIDE {} + uint32_t NextMessageSize() GRPC_OVERRIDE {return UINT_MAX;} bool Read(R* msg) GRPC_OVERRIDE { return true; } bool Write(const W& msg) GRPC_OVERRIDE { return true; } bool WritesDone() GRPC_OVERRIDE { return true; } @@ -74,6 +76,7 @@ class MockClientReaderWriter GRPC_FINAL public: MockClientReaderWriter() : writes_done_(false) {} void WaitForInitialMetadata() GRPC_OVERRIDE {} + uint32_t NextMessageSize() GRPC_OVERRIDE {return UINT_MAX;} bool Read(EchoResponse* msg) GRPC_OVERRIDE { if (writes_done_) return false; msg->set_message(last_message_); From c0c38b1f19c98f4c21ac2b75ba968e0c3aeefd19 Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 17:27:11 -0700 Subject: [PATCH 07/31] Make the FCUnary class actually work and test it --- .../grpc++/impl/codegen/completion_queue.h | 8 ++++ .../grpc++/impl/codegen/method_handler_impl.h | 19 ++++----- include/grpc++/impl/codegen/server_context.h | 8 ++++ src/compiler/cpp_generator.cc | 8 ++-- test/cpp/end2end/hybrid_end2end_test.cc | 39 ++++++++++++++++++- 5 files changed, 68 insertions(+), 14 deletions(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 1b84b447050..2286f01b8a5 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -59,6 +59,8 @@ template class ServerWriter; template class ServerReaderWriter; +template +class FCUnary; template class RpcMethodHandler; template @@ -67,6 +69,8 @@ template class ServerStreamingHandler; template class BidiStreamingHandler; +template +class FCUnaryMethodHandler; class UnknownMethodHandler; class Channel; @@ -168,6 +172,8 @@ class CompletionQueue : private GrpcLibraryCodegen { friend class ::grpc::ServerWriter; template friend class ::grpc::ServerReaderWriter; + template + friend class ::grpc::FCUnary; template friend class RpcMethodHandler; template @@ -176,6 +182,8 @@ class CompletionQueue : private GrpcLibraryCodegen { friend class ServerStreamingHandler; template friend class BidiStreamingHandler; + template + friend class FCUnaryMethodHandler; friend class UnknownMethodHandler; friend class ::grpc::Server; friend class ::grpc::ServerContext; diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 2a14ef39776..293ae6a4d8d 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -193,19 +193,22 @@ class BidiStreamingHandler : public MethodHandler { // A wrapper class of an application provided rpc method handler // specifically to apply to the flow-controlled implementation of a unary -// method +// method. +/// The argument to the constructor should be a member function already +/// bound to the appropriate service instance. The declaration gets too complicated +/// otherwise. template class FCUnaryMethodHandler : public MethodHandler { public: - FCUnaryMethodHandler(std::function*)> - func, ServiceType* service) - : func_(func), service_(service) {} + func) + : func_(func) {} void RunHandler(const HandlerParameter& param) GRPC_FINAL { FCUnary fc_unary(param.call, param.server_context); - Status status = func_(service_, param.server_context, &fc_unary); + Status status = func_(param.server_context, &fc_unary); if (!param.server_context->sent_initial_metadata_) { // means that the write never happened, which is bad } else { @@ -216,12 +219,10 @@ class FCUnaryMethodHandler : public MethodHandler { } } private: - // Application provided rpc handler function. - std::function*)> func_; - // The class the above handler function lives in. - ServiceType* service_; }; // Handle unknown method by returning UNIMPLEMENTED error. diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index a1e1ed176f6..8a925d8037c 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -67,6 +67,8 @@ template class ServerWriter; template class ServerReaderWriter; +template +class FCUnary; template class RpcMethodHandler; template @@ -75,6 +77,8 @@ template class ServerStreamingHandler; template class BidiStreamingHandler; +template +class FCUnaryMethodHandler; class UnknownMethodHandler; class Call; @@ -177,6 +181,8 @@ class ServerContext { friend class ::grpc::ServerWriter; template friend class ::grpc::ServerReaderWriter; + template + friend class ::grpc::FCUnary; template friend class RpcMethodHandler; template @@ -185,6 +191,8 @@ class ServerContext { friend class ServerStreamingHandler; template friend class BidiStreamingHandler; + template + friend class FCUnaryMethodHandler; friend class UnknownMethodHandler; friend class ::grpc::ClientContext; diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index da89d433b12..9b493fe9269 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -626,11 +626,11 @@ void PrintHeaderServerMethodFCUnary( printer->Indent(); printer->Print(*vars, "WithFCUnaryMethod_$Method$() {\n" - " ::grpc::Status (*fn)(::grpc::ServerContext*, ::grpc::FCUnary< $Request$,$Response$>*) = this->WithFCUnaryMethod_$Method$::$Method$;\n" " ::grpc::Service::MarkMethodFCUnary($Idx$,\n" " new ::grpc::FCUnaryMethodHandler(fn, this));\n" + "$Response$>(" + "std::bind(&WithFCUnaryMethod_$Method$::FC$Method$, this, std::placeholders::_1, std::placeholders::_2)));\n" "}\n"); printer->Print(*vars, "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n" @@ -648,9 +648,9 @@ void PrintHeaderServerMethodFCUnary( printer->Print( *vars, "// replace default version of this method with FCUnary\n" - "::grpc::Status $Method$(" + "virtual ::grpc::Status FC$Method$(" "::grpc::ServerContext* context, ::grpc::FCUnary< $Request$,$Response$>* fc_unary)" - " GRPC_FINAL GRPC_OVERRIDE;\n"); + " = 0;\n"); printer->Outdent(); printer->Print(*vars, "};\n"); } diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index 7e0c0e8a7ca..699cf49b260 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -199,7 +199,7 @@ class HybridEnd2endTest : public ::testing::Test { HybridEnd2endTest() {} void SetUpServer(::grpc::Service* service1, ::grpc::Service* service2, - AsyncGenericService* generic_service) { + AsyncGenericService* generic_service, int max_message_size = 0) { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; @@ -217,6 +217,11 @@ class HybridEnd2endTest : public ::testing::Test { if (generic_service) { builder.RegisterAsyncGenericService(generic_service); } + + if (max_message_size != 0) { + builder.SetMaxMessageSize(max_message_size); + } + // Create a separate cq for each potential handler. for (int i = 0; i < 5; i++) { cqs_.push_back(builder.AddCompletionQueue(false)); @@ -415,6 +420,38 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) { request_stream_handler_thread.join(); } +// Add a second service with one sync FCUnary method. +class FCUnaryDupPkg : public duplicate::EchoTestService::WithFCUnaryMethod_Echo { +public: + Status FCEcho(ServerContext* context, FCUnary* fc_unary) GRPC_OVERRIDE { + EchoRequest req; + EchoResponse resp; + gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", fc_unary->NextMessageSize()); + GPR_ASSERT(fc_unary->Read(&req)); + resp.set_message(req.message() + "_dup"); + GPR_ASSERT(fc_unary->Write(resp)); + return Status::OK; + } +}; + +TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService) { + typedef EchoTestService::WithAsyncMethod_RequestStream< + EchoTestService::WithAsyncMethod_ResponseStream> + SType; + SType service; + FCUnaryDupPkg dup_service; + SetUpServer(&service, &dup_service, nullptr, 8192); + ResetStub(); + std::thread response_stream_handler_thread(HandleServerStreaming, + &service, cqs_[0].get()); + std::thread request_stream_handler_thread(HandleClientStreaming, + &service, cqs_[1].get()); + TestAllMethods(); + SendEchoToDupService(); + response_stream_handler_thread.join(); + request_stream_handler_thread.join(); +} + // Add a second service with one async method. TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) { typedef EchoTestService::WithAsyncMethod_RequestStream< From 9959f3d0ec7a3e0cf9022cf17a3fbe3bcd397ad7 Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 23:19:15 -0700 Subject: [PATCH 08/31] Fix the golden file - why do we even have this lever? --- test/cpp/codegen/compiler_test_golden | 42 +++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index ef3d1aaa510..75b090a3f30 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -43,6 +43,8 @@ #include #include +#include +#include #include #include #include @@ -206,6 +208,26 @@ class ServiceA GRPC_FINAL { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } }; + template + class WithFCUnaryMethod_MethodA1 : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service *service) {} + public: + WithFCUnaryMethod_MethodA1() { + ::grpc::Service::MarkMethodFCUnary(0, + new ::grpc::FCUnaryMethodHandler(std::bind(&WithFCUnaryMethod_MethodA1::FCMethodA1, this, std::placeholders::_1, std::placeholders::_2))); + } + ~WithFCUnaryMethod_MethodA1() GRPC_OVERRIDE { + BaseClassMustBeDerivedFromService(this); + } + // disable regular version of this method + ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) GRPC_FINAL GRPC_OVERRIDE { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + // replace default version of this method with FCUnary + virtual ::grpc::Status FCMethodA1(::grpc::ServerContext* context, ::grpc::FCUnary< ::grpc::testing::Request,::grpc::testing::Response>* fc_unary) = 0; + }; }; // ServiceB leading comment 1 @@ -284,6 +306,26 @@ class ServiceB GRPC_FINAL { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } }; + template + class WithFCUnaryMethod_MethodB1 : public BaseClass { + private: + void BaseClassMustBeDerivedFromService(const Service *service) {} + public: + WithFCUnaryMethod_MethodB1() { + ::grpc::Service::MarkMethodFCUnary(0, + new ::grpc::FCUnaryMethodHandler(std::bind(&WithFCUnaryMethod_MethodB1::FCMethodB1, this, std::placeholders::_1, std::placeholders::_2))); + } + ~WithFCUnaryMethod_MethodB1() GRPC_OVERRIDE { + BaseClassMustBeDerivedFromService(this); + } + // disable regular version of this method + ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) GRPC_FINAL GRPC_OVERRIDE { + abort(); + return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); + } + // replace default version of this method with FCUnary + virtual ::grpc::Status FCMethodB1(::grpc::ServerContext* context, ::grpc::FCUnary< ::grpc::testing::Request,::grpc::testing::Response>* fc_unary) = 0; + }; }; // ServiceB trailing comment 1 From 577d1696e8d39a0226f9cbad61bf1ae9c2695f91 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 27 Jun 2016 14:48:57 -0700 Subject: [PATCH 09/31] Fix generated reflection files --- include/grpc++/ext/reflection.grpc.pb.h | 2 ++ src/cpp/ext/reflection.grpc.pb.cc | 1 + 2 files changed, 3 insertions(+) diff --git a/include/grpc++/ext/reflection.grpc.pb.h b/include/grpc++/ext/reflection.grpc.pb.h index 0b4ef861472..74e1d389d2d 100644 --- a/include/grpc++/ext/reflection.grpc.pb.h +++ b/include/grpc++/ext/reflection.grpc.pb.h @@ -74,6 +74,8 @@ #include #include +#include +#include #include #include #include diff --git a/src/cpp/ext/reflection.grpc.pb.cc b/src/cpp/ext/reflection.grpc.pb.cc index b046dfc1b8b..f4a0b97d65d 100644 --- a/src/cpp/ext/reflection.grpc.pb.cc +++ b/src/cpp/ext/reflection.grpc.pb.cc @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include From 2d04dd827ce66a54ea8ddc6c691f9c028833fd56 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 27 Jul 2016 11:35:56 -0700 Subject: [PATCH 10/31] Change API for next message size to allow a bool return value for failure cases. --- include/grpc++/impl/codegen/fc_unary.h | 5 ++++- include/grpc++/impl/codegen/sync_stream.h | 22 +++++++++++++++++----- test/cpp/end2end/hybrid_end2end_test.cc | 4 +++- test/cpp/end2end/mock_test.cc | 10 ++++++++-- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h index 22e40ab02e5..768443912b8 100644 --- a/include/grpc++/impl/codegen/fc_unary.h +++ b/include/grpc++/impl/codegen/fc_unary.h @@ -56,7 +56,10 @@ template public: FCUnary(Call* call, ServerContext* ctx): call_(call), ctx_(ctx), read_done_(false), write_done_(false) {} ~FCUnary() {} - uint32_t NextMessageSize() {return call_->max_message_size();} + bool NextMessageSize(uint32_t *sz) { + *sz = call_->max_message_size(); + return true; + } bool Read(RequestType *request) { if (read_done_) { return false; diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 0afa8b6aa49..930c72056c2 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -71,7 +71,7 @@ class ReaderInterface { virtual ~ReaderInterface() {} /// Upper bound on the next message size available for reading on this stream - virtual uint32_t NextMessageSize() = 0; + virtual bool NextMessageSize(uint32_t *sz) = 0; /// Blocking read a message and parse to \a msg. Returns \a true on success. /// This is thread-safe with respect to \a Write or \WritesDone methods on @@ -151,7 +151,10 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { cq_.Pluck(&ops); /// status ignored } - uint32_t NextMessageSize() GRPC_OVERRIDE {return call_.max_message_size();} + bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + *sz = call_.max_message_size(); + return true; + } bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; @@ -298,7 +301,10 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { cq_.Pluck(&ops); // status ignored } - uint32_t NextMessageSize() GRPC_OVERRIDE {return call_.max_message_size();} + bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + *sz = call_.max_message_size(); + return true; + } bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; @@ -359,7 +365,10 @@ class ServerReader GRPC_FINAL : public ReaderInterface { call_->cq()->Pluck(&ops); } - uint32_t NextMessageSize() GRPC_OVERRIDE {return call_->max_message_size();} + bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + *sz = call_->max_message_size(); + return true; + } bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; @@ -427,7 +436,10 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface, call_->cq()->Pluck(&ops); } - uint32_t NextMessageSize() GRPC_OVERRIDE {return call_->max_message_size();} + bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + *sz = call_->max_message_size(); + return true; + } bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index 699cf49b260..b80010e8031 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -426,7 +426,9 @@ public: Status FCEcho(ServerContext* context, FCUnary* fc_unary) GRPC_OVERRIDE { EchoRequest req; EchoResponse resp; - gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", fc_unary->NextMessageSize()); + uint32_t next_msg_sz; + fc_unary->NextMessageSize(&next_msg_sz); + gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", next_msg_sz); GPR_ASSERT(fc_unary->Read(&req)); resp.set_message(req.message() + "_dup"); GPR_ASSERT(fc_unary->Write(resp)); diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 744a7cd9eb9..40526271221 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -64,7 +64,10 @@ class MockClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { public: void WaitForInitialMetadata() GRPC_OVERRIDE {} - uint32_t NextMessageSize() GRPC_OVERRIDE {return UINT_MAX;} + bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { + *sz = UINT_MAX; + return true; + } bool Read(R* msg) GRPC_OVERRIDE { return true; } bool Write(const W& msg) GRPC_OVERRIDE { return true; } bool WritesDone() GRPC_OVERRIDE { return true; } @@ -76,7 +79,10 @@ class MockClientReaderWriter GRPC_FINAL public: MockClientReaderWriter() : writes_done_(false) {} void WaitForInitialMetadata() GRPC_OVERRIDE {} - uint32_t NextMessageSize() GRPC_OVERRIDE {return UINT_MAX;} + bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { + *sz = UINT_MAX; + return true; + } bool Read(EchoResponse* msg) GRPC_OVERRIDE { if (writes_done_) return false; msg->set_message(last_message_); From 581097fe0dc321a31cedae97057838fa1eadf8b2 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 10:50:51 -0700 Subject: [PATCH 11/31] Make FCUnary and ServerReaderWriter derived classes of a new ServerReaderWriterInterface so that some functions can be made to accept either. --- .../grpc++/impl/codegen/completion_queue.h | 8 +--- include/grpc++/impl/codegen/fc_unary.h | 44 +++++-------------- include/grpc++/impl/codegen/server_context.h | 8 +--- include/grpc++/impl/codegen/sync_stream.h | 26 ++++++----- src/compiler/cpp_generator.cc | 1 + 5 files changed, 32 insertions(+), 55 deletions(-) diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 1d00bf2d1bf..95ece77ce5c 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -69,9 +69,7 @@ class ServerReader; template class ServerWriter; template -class ServerReaderWriter; -template -class FCUnary; +class ServerReaderWriterInterface; template class RpcMethodHandler; template @@ -182,9 +180,7 @@ class CompletionQueue : private GrpcLibraryCodegen { template friend class ::grpc::ServerWriter; template - friend class ::grpc::ServerReaderWriter; - template - friend class ::grpc::FCUnary; + friend class ::grpc::ServerReaderWriterInterface; template friend class RpcMethodHandler; template diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h index 768443912b8..9dbc4024bf1 100644 --- a/include/grpc++/impl/codegen/fc_unary.h +++ b/include/grpc++/impl/codegen/fc_unary.h @@ -37,11 +37,10 @@ #include #include #include -#include #include +#include namespace grpc { - /// A class to represent a flow-controlled unary call. This is something /// of a hybrid between conventional unary and streaming. This is invoked /// through a unary call on the client side, but the server responds to it @@ -52,51 +51,32 @@ namespace grpc { /// and exactly 1 Write, in that order, to function correctly. /// Otherwise, the RPC is in error. template - class FCUnary GRPC_FINAL { - public: - FCUnary(Call* call, ServerContext* ctx): call_(call), ctx_(ctx), read_done_(false), write_done_(false) {} + class FCUnary GRPC_FINAL : public ServerReaderWriterInterface { +public: + FCUnary(Call* call, ServerContext* ctx): ServerReaderWriterInterface(call, ctx) , read_done_(false), write_done_(false) {} + ~FCUnary() {} - bool NextMessageSize(uint32_t *sz) { - *sz = call_->max_message_size(); - return true; - } - bool Read(RequestType *request) { + + bool Read(RequestType *request) GRPC_OVERRIDE { if (read_done_) { return false; } read_done_ = true; - CallOpSet> ops; - ops.RecvMessage(request); - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops) && ops.got_message; + return ServerReaderWriterInterface::Read(request); } - bool Write(const ResponseType& response) {return Write(response, WriteOptions());} - bool Write(const ResponseType& response, const WriteOptions& options) { + + using WriterInterface::Write; + bool Write(const ResponseType& response, const WriteOptions& options) GRPC_OVERRIDE { if (write_done_ || !read_done_) { return false; } write_done_ = true; - CallOpSet ops; - if (!ops.SendMessage(response, options).ok()) { - return false; - } - if (!ctx_->sent_initial_metadata_) { - ops.SendInitialMetadata(ctx_->initial_metadata_, - ctx_->initial_metadata_flags()); - ctx_->sent_initial_metadata_ = true; - } else { - return false; - } - call_->PerformOps(&ops); - return call_->cq()->Pluck(&ops); + return ServerReaderWriterInterface::Write(response, options); } private: - Call* const call_; - ServerContext* const ctx_; bool read_done_; bool write_done_; }; - } // namespace grpc #endif // GRPCXX_IMPL_CODEGEN_FC_UNARY_H diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index e1d7e980a16..aadae893ad3 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -66,9 +66,7 @@ class ServerReader; template class ServerWriter; template -class ServerReaderWriter; -template -class FCUnary; +class ServerReaderWriterInterface; template class RpcMethodHandler; template @@ -187,9 +185,7 @@ class ServerContext { template friend class ::grpc::ServerWriter; template - friend class ::grpc::ServerReaderWriter; - template - friend class ::grpc::FCUnary; + friend class ::grpc::ServerReaderWriterInterface; template friend class RpcMethodHandler; template diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 31da2cbbe96..2e63479961f 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -429,12 +429,11 @@ class ServerWriter GRPC_FINAL : public WriterInterface { /// Server-side interface for bi-directional streaming. template -class ServerReaderWriter GRPC_FINAL : public WriterInterface, - public ReaderInterface { - public: - ServerReaderWriter(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} - - void SendInitialMetadata() { +class ServerReaderWriterInterface : public WriterInterface, + public ReaderInterface { +public: + ServerReaderWriterInterface(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + virtual void SendInitialMetadata() { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); CallOpSet ops; @@ -448,12 +447,12 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface, call_->cq()->Pluck(&ops); } - bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + virtual bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { *sz = call_->max_message_size(); return true; } - bool Read(R* msg) GRPC_OVERRIDE { + virtual bool Read(R* msg) GRPC_OVERRIDE { CallOpSet> ops; ops.RecvMessage(msg); call_->PerformOps(&ops); @@ -461,7 +460,7 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface, } using WriterInterface::Write; - bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { + virtual bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { CallOpSet ops; if (!ops.SendMessage(msg, options).ok()) { return false; @@ -477,12 +476,17 @@ class ServerReaderWriter GRPC_FINAL : public WriterInterface, call_->PerformOps(&ops); return call_->cq()->Pluck(&ops); } - - private: +private: Call* const call_; ServerContext* const ctx_; }; +template +class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface { +public: + ServerReaderWriter(Call* call, ServerContext* ctx) : ServerReaderWriterInterface(call, ctx) {} +}; + } // namespace grpc #endif // GRPCXX_IMPL_CODEGEN_SYNC_STREAM_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index dcf995ff61a..d587023c65b 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -131,6 +131,7 @@ grpc::string GetHeaderIncludes(File *file, const Parameters ¶ms) { "grpc++/impl/codegen/async_stream.h", "grpc++/impl/codegen/async_unary_call.h", "grpc++/impl/codegen/fc_unary.h", + "grpc++/impl/codegen/method_handler_impl.h", "grpc++/impl/codegen/proto_utils.h", "grpc++/impl/codegen/rpc_method.h", "grpc++/impl/codegen/service_type.h", From ff91dea14999225e5f6c9bcf565f28ee3acce6dd Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 11:07:50 -0700 Subject: [PATCH 12/31] Be able to specify FCUnaryService just like AsyncService so that all relevant methods get treated this way. --- src/compiler/cpp_generator.cc | 16 ++++++++++++ test/cpp/end2end/hybrid_end2end_test.cc | 34 +++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index d587023c65b..29007b5e1d0 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -826,6 +826,22 @@ void PrintHeaderService(Printer *printer, const Service *service, PrintHeaderServerMethodFCUnary(printer, service->method(i).get(), vars); } + printer->Print("typedef "); + for (int i = 0; i < service->method_count(); ++i) { + (*vars)["method_name"] = service->method(i).get()->name(); + if (service->method(i)->NoStreaming()) { + printer->Print(*vars, "WithFCUnaryMethod_$method_name$<"); + } + } + printer->Print("Service"); + for (int i = 0; i < service->method_count(); ++i) { + if (service->method(i)->NoStreaming()) { + printer->Print(" >"); + } + } + printer->Print(" FCUnaryService;\n"); + + printer->Outdent(); printer->Print("};\n"); printer->Print(service->GetTrailingComments().c_str()); diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index b80010e8031..a1a964a9d38 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -454,6 +454,40 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService request_stream_handler_thread.join(); } +// Add a second service that is fully FCUnary +class FullyFCUnaryDupPkg : public duplicate::EchoTestService::FCUnaryService { +public: + Status FCEcho(ServerContext* context, FCUnary* fc_unary) GRPC_OVERRIDE { + EchoRequest req; + EchoResponse resp; + uint32_t next_msg_sz; + fc_unary->NextMessageSize(&next_msg_sz); + gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", next_msg_sz); + GPR_ASSERT(fc_unary->Read(&req)); + resp.set_message(req.message() + "_dup"); + GPR_ASSERT(fc_unary->Write(resp)); + return Status::OK; + } +}; + +TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFullyFCUnaryDupService) { + typedef EchoTestService::WithAsyncMethod_RequestStream< + EchoTestService::WithAsyncMethod_ResponseStream> + SType; + SType service; + FullyFCUnaryDupPkg dup_service; + SetUpServer(&service, &dup_service, nullptr, 8192); + ResetStub(); + std::thread response_stream_handler_thread(HandleServerStreaming, + &service, cqs_[0].get()); + std::thread request_stream_handler_thread(HandleClientStreaming, + &service, cqs_[1].get()); + TestAllMethods(); + SendEchoToDupService(); + response_stream_handler_thread.join(); + request_stream_handler_thread.join(); +} + // Add a second service with one async method. TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) { typedef EchoTestService::WithAsyncMethod_RequestStream< From 5d94118d0d3e11b0333251fec219e4571f6a20e7 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 11:48:47 -0700 Subject: [PATCH 13/31] clang-format --- include/grpc++/impl/codegen/fc_unary.h | 26 +++++++---- .../grpc++/impl/codegen/method_handler_impl.h | 19 ++++---- include/grpc++/impl/codegen/rpc_method.h | 2 +- .../grpc++/impl/codegen/rpc_service_method.h | 2 +- include/grpc++/impl/codegen/service_type.h | 2 +- include/grpc++/impl/codegen/sync_stream.h | 25 ++++++----- src/compiler/cpp_generator.cc | 45 ++++++++++--------- test/cpp/end2end/hybrid_end2end_test.cc | 22 +++++---- 8 files changed, 81 insertions(+), 62 deletions(-) diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h index 9dbc4024bf1..a423f1f0b3e 100644 --- a/include/grpc++/impl/codegen/fc_unary.h +++ b/include/grpc++/impl/codegen/fc_unary.h @@ -51,28 +51,36 @@ namespace grpc { /// and exactly 1 Write, in that order, to function correctly. /// Otherwise, the RPC is in error. template - class FCUnary GRPC_FINAL : public ServerReaderWriterInterface { -public: - FCUnary(Call* call, ServerContext* ctx): ServerReaderWriterInterface(call, ctx) , read_done_(false), write_done_(false) {} +class FCUnary GRPC_FINAL + : public ServerReaderWriterInterface { + public: + FCUnary(Call* call, ServerContext* ctx) + : ServerReaderWriterInterface(call, ctx), + read_done_(false), + write_done_(false) {} ~FCUnary() {} - bool Read(RequestType *request) GRPC_OVERRIDE { + bool Read(RequestType* request) GRPC_OVERRIDE { if (read_done_) { - return false; + return false; } read_done_ = true; - return ServerReaderWriterInterface::Read(request); + return ServerReaderWriterInterface::Read( + request); } using WriterInterface::Write; - bool Write(const ResponseType& response, const WriteOptions& options) GRPC_OVERRIDE { + bool Write(const ResponseType& response, + const WriteOptions& options) GRPC_OVERRIDE { if (write_done_ || !read_done_) { - return false; + return false; } write_done_ = true; - return ServerReaderWriterInterface::Write(response, options); + return ServerReaderWriterInterface::Write( + response, options); } + private: bool read_done_; bool write_done_; diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 14247b1f036..9c3af53b3a3 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -207,19 +207,20 @@ class BidiStreamingHandler : public MethodHandler { // specifically to apply to the flow-controlled implementation of a unary // method. /// The argument to the constructor should be a member function already -/// bound to the appropriate service instance. The declaration gets too complicated +/// bound to the appropriate service instance. The declaration gets too +/// complicated /// otherwise. template class FCUnaryMethodHandler : public MethodHandler { public: - FCUnaryMethodHandler(std::function*)> - func) - : func_(func) {} + FCUnaryMethodHandler( + std::function*)> + func) + : func_(func) {} void RunHandler(const HandlerParameter& param) GRPC_FINAL { FCUnary fc_unary(param.call, - param.server_context); + param.server_context); Status status = func_(param.server_context, &fc_unary); if (!param.server_context->sent_initial_metadata_) { // means that the write never happened, which is bad @@ -230,11 +231,11 @@ class FCUnaryMethodHandler : public MethodHandler { param.call->cq()->Pluck(&ops); } } + private: // Application provided rpc handler function, already bound to its service. - std::function*)> - func_; + std::function*)> + func_; }; // Handle unknown method by returning UNIMPLEMENTED error. diff --git a/include/grpc++/impl/codegen/rpc_method.h b/include/grpc++/impl/codegen/rpc_method.h index 728ba3e334d..b55d7550751 100644 --- a/include/grpc++/impl/codegen/rpc_method.h +++ b/include/grpc++/impl/codegen/rpc_method.h @@ -47,7 +47,7 @@ class RpcMethod { CLIENT_STREAMING, // request streaming SERVER_STREAMING, // response streaming BIDI_STREAMING, - FC_UNARY // flow-controlled unary call + FC_UNARY // flow-controlled unary call }; RpcMethod(const char* name, RpcType type) diff --git a/include/grpc++/impl/codegen/rpc_service_method.h b/include/grpc++/impl/codegen/rpc_service_method.h index 02da2a26177..52124fba0b8 100644 --- a/include/grpc++/impl/codegen/rpc_service_method.h +++ b/include/grpc++/impl/codegen/rpc_service_method.h @@ -82,7 +82,7 @@ class RpcServiceMethod : public RpcMethod { // if MethodHandler is nullptr, then this is an async method MethodHandler* handler() const { return handler_.get(); } void ResetHandler() { handler_.reset(); } - void SetHandler(MethodHandler *handler) { handler_.reset(handler); } + void SetHandler(MethodHandler* handler) { handler_.reset(handler); } private: void* server_tag_; diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h index c0eeace8a4b..dcfc6b01b7b 100644 --- a/include/grpc++/impl/codegen/service_type.h +++ b/include/grpc++/impl/codegen/service_type.h @@ -149,7 +149,7 @@ class Service { void MarkMethodFCUnary(int index, MethodHandler* fc_unary_method) { GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() && - "Cannot mark an async or generic method as FCUnary"); + "Cannot mark an async or generic method as FCUnary"); methods_[index]->SetMethodType(::grpc::RpcMethod::FC_UNARY); methods_[index]->SetHandler(fc_unary_method); } diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 2e63479961f..d9b7e6fec56 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -71,7 +71,7 @@ class ReaderInterface { virtual ~ReaderInterface() {} /// Upper bound on the next message size available for reading on this stream - virtual bool NextMessageSize(uint32_t *sz) = 0; + virtual bool NextMessageSize(uint32_t* sz) = 0; /// Blocking read a message and parse to \a msg. Returns \a true on success. /// This is thread-safe with respect to \a Write or \WritesDone methods on @@ -151,7 +151,7 @@ class ClientReader GRPC_FINAL : public ClientReaderInterface { cq_.Pluck(&ops); /// status ignored } - bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { *sz = call_.max_message_size(); return true; } @@ -301,7 +301,7 @@ class ClientReaderWriter GRPC_FINAL : public ClientReaderWriterInterface { cq_.Pluck(&ops); // status ignored } - bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { *sz = call_.max_message_size(); return true; } @@ -368,7 +368,7 @@ class ServerReader GRPC_FINAL : public ReaderInterface { call_->cq()->Pluck(&ops); } - bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { *sz = call_->max_message_size(); return true; } @@ -431,8 +431,9 @@ class ServerWriter GRPC_FINAL : public WriterInterface { template class ServerReaderWriterInterface : public WriterInterface, public ReaderInterface { -public: - ServerReaderWriterInterface(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + public: + ServerReaderWriterInterface(Call* call, ServerContext* ctx) + : call_(call), ctx_(ctx) {} virtual void SendInitialMetadata() { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); @@ -447,7 +448,7 @@ public: call_->cq()->Pluck(&ops); } - virtual bool NextMessageSize(uint32_t *sz) GRPC_OVERRIDE { + virtual bool NextMessageSize(uint32_t* sz) GRPC_OVERRIDE { *sz = call_->max_message_size(); return true; } @@ -476,15 +477,17 @@ public: call_->PerformOps(&ops); return call_->cq()->Pluck(&ops); } -private: + + private: Call* const call_; ServerContext* const ctx_; }; template -class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface { -public: - ServerReaderWriter(Call* call, ServerContext* ctx) : ServerReaderWriterInterface(call, ctx) {} +class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface { + public: + ServerReaderWriter(Call* call, ServerContext* ctx) + : ServerReaderWriterInterface(call, ctx) {} }; } // namespace grpc diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 29007b5e1d0..252a92d971e 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -607,8 +607,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method, } void PrintHeaderServerMethodFCUnary( - Printer *printer, - const Method *method, + Printer *printer, const Method *method, std::map *vars) { (*vars)["Method"] = method->name(); (*vars)["Request"] = method->input_type_name(); @@ -616,24 +615,27 @@ void PrintHeaderServerMethodFCUnary( if (method->NoStreaming()) { printer->Print(*vars, "template \n"); printer->Print(*vars, - "class WithFCUnaryMethod_$Method$ : public BaseClass {\n"); + "class WithFCUnaryMethod_$Method$ : public BaseClass {\n"); printer->Print( - " private:\n" - " void BaseClassMustBeDerivedFromService(const Service *service) {}\n"); + " private:\n" + " void BaseClassMustBeDerivedFromService(const Service *service) " + "{}\n"); printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, - "WithFCUnaryMethod_$Method$() {\n" - " ::grpc::Service::MarkMethodFCUnary($Idx$,\n" - " new ::grpc::FCUnaryMethodHandler(" - "std::bind(&WithFCUnaryMethod_$Method$::FC$Method$, this, std::placeholders::_1, std::placeholders::_2)));\n" - "}\n"); + "WithFCUnaryMethod_$Method$() {\n" + " ::grpc::Service::MarkMethodFCUnary($Idx$,\n" + " new ::grpc::FCUnaryMethodHandler(" + "std::bind(&WithFCUnaryMethod_$Method$::FC$" + "Method$, this, std::placeholders::_1, " + "std::placeholders::_2)));\n" + "}\n"); printer->Print(*vars, - "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n" - " BaseClassMustBeDerivedFromService(this);\n" - "}\n"); + "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n" + " BaseClassMustBeDerivedFromService(this);\n" + "}\n"); printer->Print( *vars, "// disable regular version of this method\n" @@ -643,12 +645,12 @@ void PrintHeaderServerMethodFCUnary( " abort();\n" " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); - printer->Print( - *vars, - "// replace default version of this method with FCUnary\n" - "virtual ::grpc::Status FC$Method$(" - "::grpc::ServerContext* context, ::grpc::FCUnary< $Request$,$Response$>* fc_unary)" - " = 0;\n"); + printer->Print(*vars, + "// replace default version of this method with FCUnary\n" + "virtual ::grpc::Status FC$Method$(" + "::grpc::ServerContext* context, ::grpc::FCUnary< " + "$Request$,$Response$>* fc_unary)" + " = 0;\n"); printer->Outdent(); printer->Print(*vars, "};\n"); } @@ -841,7 +843,6 @@ void PrintHeaderService(Printer *printer, const Service *service, } printer->Print(" FCUnaryService;\n"); - printer->Outdent(); printer->Print("};\n"); printer->Print(service->GetTrailingComments().c_str()); diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index a1a964a9d38..1512e99a3c2 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -199,7 +199,8 @@ class HybridEnd2endTest : public ::testing::Test { HybridEnd2endTest() {} void SetUpServer(::grpc::Service* service1, ::grpc::Service* service2, - AsyncGenericService* generic_service, int max_message_size = 0) { + AsyncGenericService* generic_service, + int max_message_size = 0) { int port = grpc_pick_unused_port_or_die(); server_address_ << "localhost:" << port; @@ -421,9 +422,11 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) { } // Add a second service with one sync FCUnary method. -class FCUnaryDupPkg : public duplicate::EchoTestService::WithFCUnaryMethod_Echo { -public: - Status FCEcho(ServerContext* context, FCUnary* fc_unary) GRPC_OVERRIDE { +class FCUnaryDupPkg : public duplicate::EchoTestService::WithFCUnaryMethod_Echo< + TestServiceImplDupPkg> { + public: + Status FCEcho(ServerContext* context, + FCUnary* fc_unary) GRPC_OVERRIDE { EchoRequest req; EchoResponse resp; uint32_t next_msg_sz; @@ -436,7 +439,8 @@ public: } }; -TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService) { +TEST_F(HybridEnd2endTest, + AsyncRequestStreamResponseStream_SyncFCUnaryDupService) { typedef EchoTestService::WithAsyncMethod_RequestStream< EchoTestService::WithAsyncMethod_ResponseStream> SType; @@ -456,8 +460,9 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService // Add a second service that is fully FCUnary class FullyFCUnaryDupPkg : public duplicate::EchoTestService::FCUnaryService { -public: - Status FCEcho(ServerContext* context, FCUnary* fc_unary) GRPC_OVERRIDE { + public: + Status FCEcho(ServerContext* context, + FCUnary* fc_unary) GRPC_OVERRIDE { EchoRequest req; EchoResponse resp; uint32_t next_msg_sz; @@ -470,7 +475,8 @@ public: } }; -TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFullyFCUnaryDupService) { +TEST_F(HybridEnd2endTest, + AsyncRequestStreamResponseStream_SyncFullyFCUnaryDupService) { typedef EchoTestService::WithAsyncMethod_RequestStream< EchoTestService::WithAsyncMethod_ResponseStream> SType; From 6d214bcff7d009ff63659d5a2551326364128c04 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 12:03:12 -0700 Subject: [PATCH 14/31] Add FCService to golden test --- test/cpp/codegen/compiler_test_golden | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 75b090a3f30..47519289450 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -228,6 +228,7 @@ class ServiceA GRPC_FINAL { // replace default version of this method with FCUnary virtual ::grpc::Status FCMethodA1(::grpc::ServerContext* context, ::grpc::FCUnary< ::grpc::testing::Request,::grpc::testing::Response>* fc_unary) = 0; }; + typedef WithFCUnaryMethod_MethodA1 FCUnaryService; }; // ServiceB leading comment 1 @@ -326,6 +327,7 @@ class ServiceB GRPC_FINAL { // replace default version of this method with FCUnary virtual ::grpc::Status FCMethodB1(::grpc::ServerContext* context, ::grpc::FCUnary< ::grpc::testing::Request,::grpc::testing::Response>* fc_unary) = 0; }; + typedef WithFCUnaryMethod_MethodB1 FCUnaryService; }; // ServiceB trailing comment 1 From 435429575c5f111b5232f5e0af25fdcec18a7ee2 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 13:47:06 -0700 Subject: [PATCH 15/31] generate projects --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index c9d28e6553d..b6a079f05ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1077,6 +1077,7 @@ foreach(_hdr include/grpc++/support/byte_buffer.h include/grpc++/support/channel_arguments.h include/grpc++/support/config.h + include/grpc++/support/fc_unary.h include/grpc++/support/slice.h include/grpc++/support/status.h include/grpc++/support/status_code_enum.h @@ -1096,6 +1097,7 @@ foreach(_hdr include/grpc++/impl/codegen/config.h include/grpc++/impl/codegen/core_codegen_interface.h include/grpc++/impl/codegen/create_auth_context.h + include/grpc++/impl/codegen/fc_unary.h include/grpc++/impl/codegen/grpc_library.h include/grpc++/impl/codegen/method_handler_impl.h include/grpc++/impl/codegen/rpc_method.h @@ -1188,6 +1190,7 @@ foreach(_hdr include/grpc++/impl/codegen/config.h include/grpc++/impl/codegen/core_codegen_interface.h include/grpc++/impl/codegen/create_auth_context.h + include/grpc++/impl/codegen/fc_unary.h include/grpc++/impl/codegen/grpc_library.h include/grpc++/impl/codegen/method_handler_impl.h include/grpc++/impl/codegen/rpc_method.h @@ -1333,6 +1336,7 @@ foreach(_hdr include/grpc++/support/byte_buffer.h include/grpc++/support/channel_arguments.h include/grpc++/support/config.h + include/grpc++/support/fc_unary.h include/grpc++/support/slice.h include/grpc++/support/status.h include/grpc++/support/status_code_enum.h @@ -1352,6 +1356,7 @@ foreach(_hdr include/grpc++/impl/codegen/config.h include/grpc++/impl/codegen/core_codegen_interface.h include/grpc++/impl/codegen/create_auth_context.h + include/grpc++/impl/codegen/fc_unary.h include/grpc++/impl/codegen/grpc_library.h include/grpc++/impl/codegen/method_handler_impl.h include/grpc++/impl/codegen/rpc_method.h From 326d939873eb96c68d3ebb859c12b4bf022dadc6 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 14:10:54 -0700 Subject: [PATCH 16/31] Another golden file to fix --- include/grpc++/ext/reflection.grpc.pb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/grpc++/ext/reflection.grpc.pb.h b/include/grpc++/ext/reflection.grpc.pb.h index 74e1d389d2d..18ec2ea1ecc 100644 --- a/include/grpc++/ext/reflection.grpc.pb.h +++ b/include/grpc++/ext/reflection.grpc.pb.h @@ -176,6 +176,7 @@ class ServerReflection GRPC_FINAL { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } }; + typedef Service FCUnaryService; }; } // namespace v1alpha From 9c74487072abdef96ed1bd49c131aaf22fee5238 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Fri, 12 Aug 2016 14:58:10 -0700 Subject: [PATCH 17/31] Use thread pool from concurrent-ruby on ruby server --- grpc.gemspec | 1 + src/ruby/lib/grpc/generic/rpc_server.rb | 143 +++--------------- src/ruby/spec/generic/rpc_server_pool_spec.rb | 138 ----------------- src/ruby/spec/generic/rpc_server_spec.rb | 13 +- 4 files changed, 32 insertions(+), 263 deletions(-) delete mode 100644 src/ruby/spec/generic/rpc_server_pool_spec.rb diff --git a/grpc.gemspec b/grpc.gemspec index 29d8afef9b9..1b2c553dd37 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -29,6 +29,7 @@ Gem::Specification.new do |s| s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.3' s.add_dependency 'googleauth', '~> 0.5.1' + s.add_dependency 'concurrent-ruby' s.add_development_dependency 'bundler', '~> 1.9' s.add_development_dependency 'facter', '~> 2.4' diff --git a/src/ruby/lib/grpc/generic/rpc_server.rb b/src/ruby/lib/grpc/generic/rpc_server.rb index 8ea798dce06..da0f6503db3 100644 --- a/src/ruby/lib/grpc/generic/rpc_server.rb +++ b/src/ruby/lib/grpc/generic/rpc_server.rb @@ -31,113 +31,10 @@ require_relative '../grpc' require_relative 'active_call' require_relative 'service' require 'thread' +require 'concurrent' # GRPC contains the General RPC module. module GRPC - # Pool is a simple thread pool. - class Pool - # Default keep alive period is 1s - DEFAULT_KEEP_ALIVE = 1 - - def initialize(size, keep_alive: DEFAULT_KEEP_ALIVE) - fail 'pool size must be positive' unless size > 0 - @jobs = Queue.new - @size = size - @stopped = false - @stop_mutex = Mutex.new # needs to be held when accessing @stopped - @stop_cond = ConditionVariable.new - @workers = [] - @keep_alive = keep_alive - end - - # Returns the number of jobs waiting - def jobs_waiting - @jobs.size - end - - # Runs the given block on the queue with the provided args. - # - # @param args the args passed blk when it is called - # @param blk the block to call - def schedule(*args, &blk) - return if blk.nil? - @stop_mutex.synchronize do - if @stopped - GRPC.logger.warn('did not schedule job, already stopped') - return - end - GRPC.logger.info('schedule another job') - @jobs << [blk, args] - end - end - - # Starts running the jobs in the thread pool. - def start - @stop_mutex.synchronize do - fail 'already stopped' if @stopped - end - until @workers.size == @size.to_i - next_thread = Thread.new do - catch(:exit) do # allows { throw :exit } to kill a thread - loop_execute_jobs - end - remove_current_thread - end - @workers << next_thread - end - end - - # Stops the jobs in the pool - def stop - GRPC.logger.info('stopping, will wait for all the workers to exit') - @workers.size.times { schedule { throw :exit } } - @stop_mutex.synchronize do # wait @keep_alive for works to stop - @stopped = true - @stop_cond.wait(@stop_mutex, @keep_alive) if @workers.size > 0 - end - forcibly_stop_workers - GRPC.logger.info('stopped, all workers are shutdown') - end - - protected - - # Forcibly shutdown any threads that are still alive. - def forcibly_stop_workers - return unless @workers.size > 0 - GRPC.logger.info("forcibly terminating #{@workers.size} worker(s)") - @workers.each do |t| - next unless t.alive? - begin - t.exit - rescue StandardError => e - GRPC.logger.warn('error while terminating a worker') - GRPC.logger.warn(e) - end - end - end - - # removes the threads from workers, and signal when all the - # threads are complete. - def remove_current_thread - @stop_mutex.synchronize do - @workers.delete(Thread.current) - @stop_cond.signal if @workers.size.zero? - end - end - - def loop_execute_jobs - loop do - begin - blk, args = @jobs.pop - blk.call(*args) - rescue StandardError => e - GRPC.logger.warn('Error in worker thread') - GRPC.logger.warn(e) - end - end - end - end - # RpcServer hosts a number of services and makes them available on the # network. class RpcServer @@ -147,11 +44,14 @@ module GRPC def_delegators :@server, :add_http2_port - # Default thread pool size is 3 - DEFAULT_POOL_SIZE = 3 + # Default max size of the thread pool size is 100 + DEFAULT_MAX_POOL_SIZE = 100 + + # Default minimum size of the thread pool is 5 + DEFAULT_MIN_POOL_SIZE = 5 - # Default max_waiting_requests size is 20 - DEFAULT_MAX_WAITING_REQUESTS = 20 + # Default max_waiting_requests size is 60 + DEFAULT_MAX_WAITING_REQUESTS = 60 # Default poll period is 1s DEFAULT_POLL_PERIOD = 1 @@ -174,8 +74,8 @@ module GRPC # There are some specific keyword args used to configure the RpcServer # instance. # - # * pool_size: the size of the thread pool the server uses to run its - # threads + # * pool_size: the maximum size of the thread pool that the server's + # thread pool can reach. # # * max_waiting_requests: the maximum number of requests that are not # being handled to allow. When this limit is exceeded, the server responds @@ -191,7 +91,8 @@ module GRPC # # * server_args: # A server arguments hash to be passed down to the underlying core server - def initialize(pool_size:DEFAULT_POOL_SIZE, + def initialize(pool_size:DEFAULT_MAX_POOL_SIZE, + min_pool_size:DEFAULT_MIN_POOL_SIZE, max_waiting_requests:DEFAULT_MAX_WAITING_REQUESTS, poll_period:DEFAULT_POLL_PERIOD, connect_md_proc:nil, @@ -199,8 +100,12 @@ module GRPC @connect_md_proc = RpcServer.setup_connect_md_proc(connect_md_proc) @max_waiting_requests = max_waiting_requests @poll_period = poll_period - @pool_size = pool_size - @pool = Pool.new(@pool_size) + + @pool = Concurrent::ThreadPoolExecutor.new( + min_threads: [min_pool_size, pool_size].min, + max_threads: pool_size, + max_queue: max_waiting_requests, + fallback_policy: :discard) @run_cond = ConditionVariable.new @run_mutex = Mutex.new # running_state can take 4 values: :not_started, :running, :stopping, and @@ -221,7 +126,8 @@ module GRPC end deadline = from_relative_time(@poll_period) @server.close(deadline) - @pool.stop + @pool.shutdown + @pool.wait_for_termination end def running_state @@ -318,7 +224,6 @@ module GRPC def run @run_mutex.synchronize do fail 'cannot run without registering services' if rpc_descs.size.zero? - @pool.start @server.start transition_running_state(:running) @run_cond.broadcast @@ -330,9 +235,11 @@ module GRPC # Sends RESOURCE_EXHAUSTED if there are too many unprocessed jobs def available?(an_rpc) - jobs_count, max = @pool.jobs_waiting, @max_waiting_requests + jobs_count, max = @pool.queue_length, @pool.max_queue GRPC.logger.info("waiting: #{jobs_count}, max: #{max}") - return an_rpc if @pool.jobs_waiting <= @max_waiting_requests + + # remaining capacity for ThreadPoolExecutors is -1 if unbounded + return an_rpc if @pool.remaining_capacity != 0 GRPC.logger.warn("NOT AVAILABLE: too many jobs_waiting: #{an_rpc}") noop = proc { |x| x } @@ -368,7 +275,7 @@ module GRPC break if (!an_rpc.nil?) && an_rpc.call.nil? active_call = new_active_server_call(an_rpc) unless active_call.nil? - @pool.schedule(active_call) do |ac| + @pool.post(active_call) do |ac| c, mth = ac begin rpc_descs[mth].run_server_method(c, rpc_handlers[mth]) diff --git a/src/ruby/spec/generic/rpc_server_pool_spec.rb b/src/ruby/spec/generic/rpc_server_pool_spec.rb deleted file mode 100644 index b67008de486..00000000000 --- a/src/ruby/spec/generic/rpc_server_pool_spec.rb +++ /dev/null @@ -1,138 +0,0 @@ -# Copyright 2015, Google Inc. -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are -# met: -# -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above -# copyright notice, this list of conditions and the following disclaimer -# in the documentation and/or other materials provided with the -# distribution. -# * Neither the name of Google Inc. nor the names of its -# contributors may be used to endorse or promote products derived from -# this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -require 'grpc' - -describe GRPC::Pool do - Pool = GRPC::Pool - - describe '#new' do - it 'raises if a non-positive size is used' do - expect { Pool.new(0) }.to raise_error - expect { Pool.new(-1) }.to raise_error - expect { Pool.new(Object.new) }.to raise_error - end - - it 'is constructed OK with a positive size' do - expect { Pool.new(1) }.not_to raise_error - end - end - - describe '#jobs_waiting' do - it 'at start, it is zero' do - p = Pool.new(1) - expect(p.jobs_waiting).to be(0) - end - - it 'it increases, with each scheduled job if the pool is not running' do - p = Pool.new(1) - job = proc {} - expect(p.jobs_waiting).to be(0) - 5.times do |i| - p.schedule(&job) - expect(p.jobs_waiting).to be(i + 1) - end - end - - it 'it decreases as jobs are run' do - p = Pool.new(1) - job = proc {} - expect(p.jobs_waiting).to be(0) - 3.times do - p.schedule(&job) - end - p.start - sleep 2 - expect(p.jobs_waiting).to be(0) - end - end - - describe '#schedule' do - it 'return if the pool is already stopped' do - p = Pool.new(1) - p.stop - job = proc {} - expect { p.schedule(&job) }.to_not raise_error - end - - it 'adds jobs that get run by the pool' do - p = Pool.new(1) - p.start - o, q = Object.new, Queue.new - job = proc { q.push(o) } - p.schedule(&job) - expect(q.pop).to be(o) - p.stop - end - end - - describe '#stop' do - it 'works when there are no scheduled tasks' do - p = Pool.new(1) - expect { p.stop }.not_to raise_error - end - - it 'stops jobs when there are long running jobs' do - p = Pool.new(1) - p.start - o, q = Object.new, Queue.new - job = proc do - sleep(5) # long running - q.push(o) - end - p.schedule(&job) - sleep(1) # should ensure the long job gets scheduled - expect { p.stop }.not_to raise_error - end - end - - describe '#start' do - it 'runs pre-scheduled jobs' do - p = Pool.new(2) - o, q = Object.new, Queue.new - n = 5 # arbitrary - n.times { p.schedule(o, &q.method(:push)) } - p.start - n.times { expect(q.pop).to be(o) } - p.stop - end - - it 'runs jobs as they are scheduled ' do - p = Pool.new(2) - o, q = Object.new, Queue.new - p.start - n = 5 # arbitrary - n.times do - p.schedule(o, &q.method(:push)) - expect(q.pop).to be(o) - end - p.stop - end - end -end diff --git a/src/ruby/spec/generic/rpc_server_spec.rb b/src/ruby/spec/generic/rpc_server_spec.rb index 31157cf161e..d362e48deee 100644 --- a/src/ruby/spec/generic/rpc_server_spec.rb +++ b/src/ruby/spec/generic/rpc_server_spec.rb @@ -395,9 +395,9 @@ describe GRPC::RpcServer do it 'should return RESOURCE_EXHAUSTED on too many jobs', server: true do opts = { server_args: { a_channel_arg: 'an_arg' }, - pool_size: 1, + pool_size: 2, poll_period: 1, - max_waiting_requests: 0 + max_waiting_requests: 1 } alt_srv = RpcServer.new(**opts) alt_srv.handle(SlowService) @@ -406,24 +406,23 @@ describe GRPC::RpcServer do t = Thread.new { alt_srv.run } alt_srv.wait_till_running req = EchoMsg.new - n = 5 # arbitrary, use as many to ensure the server pool is exceeded + n = 20 # arbitrary, use as many to ensure the server pool is exceeded threads = [] - one_failed_as_unavailable = false + bad_status_code = nil n.times do threads << Thread.new do stub = SlowStub.new(alt_host, :this_channel_is_insecure) begin stub.an_rpc(req) rescue GRPC::BadStatus => e - one_failed_as_unavailable = - e.code == StatusCodes::RESOURCE_EXHAUSTED + bad_status_code = e.code end end end threads.each(&:join) alt_srv.stop t.join - expect(one_failed_as_unavailable).to be(true) + expect(bad_status_code).to be(StatusCodes::RESOURCE_EXHAUSTED) end end From 3dd3688cd3f41cebe42c3aa0f136b609d64aef5f Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Wed, 17 Aug 2016 10:52:45 -0700 Subject: [PATCH 18/31] update gemspec in template --- templates/grpc.gemspec.template | 1 + 1 file changed, 1 insertion(+) diff --git a/templates/grpc.gemspec.template b/templates/grpc.gemspec.template index ce775ffb90b..9a41356ea3c 100644 --- a/templates/grpc.gemspec.template +++ b/templates/grpc.gemspec.template @@ -31,6 +31,7 @@ s.add_dependency 'google-protobuf', '~> 3.0.0.alpha.5.0.3' s.add_dependency 'googleauth', '~> 0.5.1' + s.add_dependency 'concurrent-ruby' s.add_development_dependency 'bundler', '~> 1.9' s.add_development_dependency 'facter', '~> 2.4' From cdc253535bb879918b9bd66b29007f27219f6e2e Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 25 Aug 2016 15:33:02 -0700 Subject: [PATCH 19/31] Remove FC_UNARY enum and treat it more like a special case of BIDI_STREAMING in all cases --- include/grpc++/impl/codegen/rpc_method.h | 3 +-- include/grpc++/impl/codegen/service_type.h | 5 ++++- src/compiler/cpp_generator.cc | 2 +- src/cpp/server/server.cc | 1 - 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/grpc++/impl/codegen/rpc_method.h b/include/grpc++/impl/codegen/rpc_method.h index b55d7550751..48974280747 100644 --- a/include/grpc++/impl/codegen/rpc_method.h +++ b/include/grpc++/impl/codegen/rpc_method.h @@ -46,8 +46,7 @@ class RpcMethod { NORMAL_RPC = 0, CLIENT_STREAMING, // request streaming SERVER_STREAMING, // response streaming - BIDI_STREAMING, - FC_UNARY // flow-controlled unary call + BIDI_STREAMING }; RpcMethod(const char* name, RpcType type) diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h index dcfc6b01b7b..4af40422a1b 100644 --- a/include/grpc++/impl/codegen/service_type.h +++ b/include/grpc++/impl/codegen/service_type.h @@ -150,8 +150,11 @@ class Service { void MarkMethodFCUnary(int index, MethodHandler* fc_unary_method) { GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() && "Cannot mark an async or generic method as FCUnary"); - methods_[index]->SetMethodType(::grpc::RpcMethod::FC_UNARY); methods_[index]->SetHandler(fc_unary_method); + + // From the server's point of view, streamed unary is a special + // case of BIDI_STREAMING that has 1 read and 1 write, in that order. + methods_[index]->SetMethodType(::grpc::RpcMethod::BIDI_STREAMING); } private: diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 252a92d971e..c5d4c2573d9 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -1154,7 +1154,7 @@ void PrintSourceService(Printer *printer, const Service *service, (*vars)["Idx"] = as_string(i); if (method->NoStreaming()) { (*vars)["StreamingType"] = "NORMAL_RPC"; - // NOTE: There is no reason to consider FC_UNARY as a separate + // NOTE: There is no reason to consider streamed-unary as a separate // category here since this part is setting up the client-side stub // and this appears as a NORMAL_RPC from the client-side. } else if (method->ClientOnlyStreaming()) { diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc index c1fbaa09f5c..af04fd4ca64 100644 --- a/src/cpp/server/server.cc +++ b/src/cpp/server/server.cc @@ -342,7 +342,6 @@ static grpc_server_register_method_payload_handling PayloadHandlingForMethod( return GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER; case RpcMethod::CLIENT_STREAMING: case RpcMethod::BIDI_STREAMING: - case RpcMethod::FC_UNARY: return GRPC_SRM_PAYLOAD_NONE; } GPR_UNREACHABLE_CODE(return GRPC_SRM_PAYLOAD_NONE;); From a9c0d7f88b213d9a5e41808fd5d1eceaff1a034f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 29 Aug 2016 16:42:04 -0700 Subject: [PATCH 20/31] Change names to StreamedUnary, ServerUnaryStreamer, etc. Use a templated method handler since most code shared between the new StreamedUnary and the existing BidiStreaming. Eliminate the separate enum case for streamed unary. Return a status failure if a StreamedUnary method handler doesn't actually do a write (since that is violating the appearance of unary-ness) --- include/grpc++/ext/reflection.grpc.pb.h | 2 +- .../grpc++/impl/codegen/completion_queue.h | 8 +- .../grpc++/impl/codegen/method_handler_impl.h | 81 ++++++++----------- include/grpc++/impl/codegen/server_context.h | 8 +- .../{fc_unary.h => server_streamed_unary.h} | 18 ++--- include/grpc++/impl/codegen/service_type.h | 7 +- .../grpc++/impl/codegen/status_code_enum.h | 5 ++ .../{fc_unary.h => server_streamed_unary.h} | 8 +- src/compiler/cpp_generator.cc | 44 +++++----- src/cpp/ext/reflection.grpc.pb.cc | 2 +- test/cpp/end2end/hybrid_end2end_test.cc | 43 +++++----- 11 files changed, 108 insertions(+), 118 deletions(-) rename include/grpc++/impl/codegen/{fc_unary.h => server_streamed_unary.h} (86%) rename include/grpc++/support/{fc_unary.h => server_streamed_unary.h} (88%) diff --git a/include/grpc++/ext/reflection.grpc.pb.h b/include/grpc++/ext/reflection.grpc.pb.h index 18ec2ea1ecc..822c2e374a8 100644 --- a/include/grpc++/ext/reflection.grpc.pb.h +++ b/include/grpc++/ext/reflection.grpc.pb.h @@ -74,10 +74,10 @@ #include #include -#include #include #include #include +#include #include #include #include diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 95ece77ce5c..ea317a7a79b 100644 --- a/include/grpc++/impl/codegen/completion_queue.h +++ b/include/grpc++/impl/codegen/completion_queue.h @@ -78,8 +78,6 @@ template class ServerStreamingHandler; template class BidiStreamingHandler; -template -class FCUnaryMethodHandler; class UnknownMethodHandler; class Channel; @@ -187,10 +185,8 @@ class CompletionQueue : private GrpcLibraryCodegen { friend class ClientStreamingHandler; template friend class ServerStreamingHandler; - template - friend class BidiStreamingHandler; - template - friend class FCUnaryMethodHandler; + template + friend class TemplatedBidiStreamingHandler; friend class UnknownMethodHandler; friend class ::grpc::Server; friend class ::grpc::ServerContext; diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 9c3af53b3a3..3a671fe830a 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -35,8 +35,8 @@ #define GRPCXX_IMPL_CODEGEN_METHOD_HANDLER_IMPL_H #include -#include #include +#include #include namespace grpc { @@ -168,20 +168,23 @@ class ServerStreamingHandler : public MethodHandler { }; // A wrapper class of an application provided bidi-streaming handler. -template -class BidiStreamingHandler : public MethodHandler { +// This also applies to server-streamed implementation of a unary method +// with the additional requirement that such methods must have done a +// write for status to be ok +// Since this is used by more than 1 class, the service is not passed in. +// Instead, it is expected to be an implicitly-captured argument of func +// (through bind or something along those lines) +template +class TemplatedBidiStreamingHandler : public MethodHandler { public: - BidiStreamingHandler( - std::function*)> - func, - ServiceType* service) - : func_(func), service_(service) {} + TemplatedBidiStreamingHandler( + std::function + func) + : func_(func), write_needed_(WriteNeeded) {} void RunHandler(const HandlerParameter& param) GRPC_FINAL { - ServerReaderWriter stream(param.call, - param.server_context); - Status status = func_(service_, param.server_context, &stream); + Streamer stream(param.call, param.server_context); + Status status = func_(param.server_context, &stream); CallOpSet ops; if (!param.server_context->sent_initial_metadata_) { @@ -190,6 +193,12 @@ class BidiStreamingHandler : public MethodHandler { if (param.server_context->compression_level_set()) { ops.set_compression_level(param.server_context->compression_level()); } + if (write_needed_ && status.ok()) { + // If we needed a write but never did one, we need to mark the + // status as a fail + status = Status(IMPROPER_IMPLEMENTATION, + "Service did not provide response message"); + } } ops.ServerSendStatus(param.server_context->trailing_metadata_, status); param.call->PerformOps(&ops); @@ -197,46 +206,24 @@ class BidiStreamingHandler : public MethodHandler { } private: - std::function*)> - func_; - ServiceType* service_; + std::function + func_; + const bool write_needed_; }; -// A wrapper class of an application provided rpc method handler -// specifically to apply to the flow-controlled implementation of a unary -// method. -/// The argument to the constructor should be a member function already -/// bound to the appropriate service instance. The declaration gets too -/// complicated -/// otherwise. template -class FCUnaryMethodHandler : public MethodHandler { + class BidiStreamingHandler : public TemplatedBidiStreamingHandler, false> { public: - FCUnaryMethodHandler( - std::function*)> - func) - : func_(func) {} + BidiStreamingHandler(std::function*)> func, ServiceType* service): TemplatedBidiStreamingHandler,false>(std::bind(func, service, std::placeholders::_1, std::placeholders::_2)) {} + }; - void RunHandler(const HandlerParameter& param) GRPC_FINAL { - FCUnary fc_unary(param.call, - param.server_context); - Status status = func_(param.server_context, &fc_unary); - if (!param.server_context->sent_initial_metadata_) { - // means that the write never happened, which is bad - } else { - CallOpSet ops; - ops.ServerSendStatus(param.server_context->trailing_metadata_, status); - param.call->PerformOps(&ops); - param.call->cq()->Pluck(&ops); - } - } - - private: - // Application provided rpc handler function, already bound to its service. - std::function*)> - func_; -}; + template + class StreamedUnaryHandler : public TemplatedBidiStreamingHandler, true> { + public: + explicit StreamedUnaryHandler(std::function*)> func): TemplatedBidiStreamingHandler, true>(func) {} + }; // Handle unknown method by returning UNIMPLEMENTED error. class UnknownMethodHandler : public MethodHandler { diff --git a/include/grpc++/impl/codegen/server_context.h b/include/grpc++/impl/codegen/server_context.h index aadae893ad3..8e101c3f15b 100644 --- a/include/grpc++/impl/codegen/server_context.h +++ b/include/grpc++/impl/codegen/server_context.h @@ -75,8 +75,6 @@ template class ServerStreamingHandler; template class BidiStreamingHandler; -template -class FCUnaryMethodHandler; class UnknownMethodHandler; class Call; @@ -192,10 +190,8 @@ class ServerContext { friend class ClientStreamingHandler; template friend class ServerStreamingHandler; - template - friend class BidiStreamingHandler; - template - friend class FCUnaryMethodHandler; + template + friend class TemplatedBidiStreamingHandler; friend class UnknownMethodHandler; friend class ::grpc::ClientContext; diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/server_streamed_unary.h similarity index 86% rename from include/grpc++/impl/codegen/fc_unary.h rename to include/grpc++/impl/codegen/server_streamed_unary.h index a423f1f0b3e..a23e6020ed2 100644 --- a/include/grpc++/impl/codegen/fc_unary.h +++ b/include/grpc++/impl/codegen/server_streamed_unary.h @@ -31,8 +31,8 @@ * */ -#ifndef GRPCXX_IMPL_CODEGEN_FC_UNARY_H -#define GRPCXX_IMPL_CODEGEN_FC_UNARY_H +#ifndef GRPCXX_IMPL_CODEGEN_SERVER_STREAMED_UNARY_H +#define GRPCXX_IMPL_CODEGEN_SERVER_STREAMED_UNARY_H #include #include @@ -47,19 +47,19 @@ namespace grpc { /// as though it were a single-ping-pong streaming call. The server can use /// the \a NextMessageSize method to determine an upper-bound on the size of /// the message. -/// A key difference relative to streaming: an FCUnary must have exactly 1 Read -/// and exactly 1 Write, in that order, to function correctly. -/// Otherwise, the RPC is in error. +/// A key difference relative to streaming: ServerUnaryStreamer +/// must have exactly 1 Read and exactly 1 Write, in that order, to function +/// correctly. Otherwise, the RPC is in error. template -class FCUnary GRPC_FINAL +class ServerUnaryStreamer GRPC_FINAL : public ServerReaderWriterInterface { public: - FCUnary(Call* call, ServerContext* ctx) + ServerUnaryStreamer(Call* call, ServerContext* ctx) : ServerReaderWriterInterface(call, ctx), read_done_(false), write_done_(false) {} - ~FCUnary() {} + ~ServerUnaryStreamer() {} bool Read(RequestType* request) GRPC_OVERRIDE { if (read_done_) { @@ -87,4 +87,4 @@ class FCUnary GRPC_FINAL }; } // namespace grpc -#endif // GRPCXX_IMPL_CODEGEN_FC_UNARY_H +#endif // GRPCXX_IMPL_CODEGEN_SERVER_STREAMED_UNARY_H diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h index 4af40422a1b..9d2a80cbc43 100644 --- a/include/grpc++/impl/codegen/service_type.h +++ b/include/grpc++/impl/codegen/service_type.h @@ -147,10 +147,11 @@ class Service { methods_[index].reset(); } - void MarkMethodFCUnary(int index, MethodHandler* fc_unary_method) { + void MarkMethodStreamedUnary(int index, + MethodHandler* streamed_unary_method) { GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() && - "Cannot mark an async or generic method as FCUnary"); - methods_[index]->SetHandler(fc_unary_method); + "Cannot mark an async or generic method Streamed Unary"); + methods_[index]->SetHandler(streamed_unary_method); // From the server's point of view, streamed unary is a special // case of BIDI_STREAMING that has 1 read and 1 write, in that order. diff --git a/include/grpc++/impl/codegen/status_code_enum.h b/include/grpc++/impl/codegen/status_code_enum.h index 9a90a18e2a5..0f18a22c366 100644 --- a/include/grpc++/impl/codegen/status_code_enum.h +++ b/include/grpc++/impl/codegen/status_code_enum.h @@ -143,6 +143,11 @@ enum StatusCode { /// Unrecoverable data loss or corruption. DATA_LOSS = 15, + // Service was improperly implemented, violated a gRPC API requirement + // Not quite the same as unimplemented since it could just be that the API + // requirement was violated in this particular circumstance + IMPROPER_IMPLEMENTATION = 16, + /// Force users to include a default branch: DO_NOT_USE = -1 }; diff --git a/include/grpc++/support/fc_unary.h b/include/grpc++/support/server_streamed_unary.h similarity index 88% rename from include/grpc++/support/fc_unary.h rename to include/grpc++/support/server_streamed_unary.h index 7e7dea8feb2..109dfd4bcab 100644 --- a/include/grpc++/support/fc_unary.h +++ b/include/grpc++/support/server_streamed_unary.h @@ -31,9 +31,9 @@ * */ -#ifndef GRPCXX_SUPPORT_FC_UNARY_H -#define GRPCXX_SUPPORT_FC_UNARY_H +#ifndef GRPCXX_SUPPORT_SERVER_STREAMED_UNARY_H +#define GRPCXX_SUPPORT_SERVER_STREAMED_UNARY_H -#include +#include -#endif // GRPCXX_SUPPORT_FC_UNARY_H +#endif // GRPCXX_SUPPORT_SERVER_STREAMED_UNARY_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index c5d4c2573d9..7c70567d120 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -130,10 +130,10 @@ grpc::string GetHeaderIncludes(File *file, const Parameters ¶ms) { static const char *headers_strs[] = { "grpc++/impl/codegen/async_stream.h", "grpc++/impl/codegen/async_unary_call.h", - "grpc++/impl/codegen/fc_unary.h", "grpc++/impl/codegen/method_handler_impl.h", "grpc++/impl/codegen/proto_utils.h", "grpc++/impl/codegen/rpc_method.h", + "grpc++/impl/codegen/server_streamed_unary.h", "grpc++/impl/codegen/service_type.h", "grpc++/impl/codegen/status.h", "grpc++/impl/codegen/stub_options.h", @@ -606,7 +606,7 @@ void PrintHeaderServerMethodAsync(Printer *printer, const Method *method, printer->Print(*vars, "};\n"); } -void PrintHeaderServerMethodFCUnary( +void PrintHeaderServerMethodStreamedUnary( Printer *printer, const Method *method, std::map *vars) { (*vars)["Method"] = method->name(); @@ -615,7 +615,8 @@ void PrintHeaderServerMethodFCUnary( if (method->NoStreaming()) { printer->Print(*vars, "template \n"); printer->Print(*vars, - "class WithFCUnaryMethod_$Method$ : public BaseClass {\n"); + "class WithStreamedUnaryMethod_$Method$ : " + "public BaseClass {\n"); printer->Print( " private:\n" " void BaseClassMustBeDerivedFromService(const Service *service) " @@ -623,17 +624,16 @@ void PrintHeaderServerMethodFCUnary( printer->Print(" public:\n"); printer->Indent(); printer->Print(*vars, - "WithFCUnaryMethod_$Method$() {\n" - " ::grpc::Service::MarkMethodFCUnary($Idx$,\n" - " new ::grpc::FCUnaryMethodHandler(" - "std::bind(&WithFCUnaryMethod_$Method$::FC$" - "Method$, this, std::placeholders::_1, " - "std::placeholders::_2)));\n" + "WithStreamedUnaryMethod_$Method$() {\n" + " ::grpc::Service::MarkMethodStreamedUnary($Idx$,\n" + " new ::grpc::StreamedUnaryHandler<$Request$, " + "$Response$>(std::bind" + "(&WithStreamedUnaryMethod_$Method$::" + "Streamed$Method$, this, std::placeholders::_1, " + "std::placeholders::_2)));\n" "}\n"); printer->Print(*vars, - "~WithFCUnaryMethod_$Method$() GRPC_OVERRIDE {\n" + "~WithStreamedUnaryMethod_$Method$() GRPC_OVERRIDE {\n" " BaseClassMustBeDerivedFromService(this);\n" "}\n"); printer->Print( @@ -646,10 +646,11 @@ void PrintHeaderServerMethodFCUnary( " return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, \"\");\n" "}\n"); printer->Print(*vars, - "// replace default version of this method with FCUnary\n" - "virtual ::grpc::Status FC$Method$(" - "::grpc::ServerContext* context, ::grpc::FCUnary< " - "$Request$,$Response$>* fc_unary)" + "// replace default version of method with streamed unary\n" + "virtual ::grpc::Status Streamed$Method$(" + "::grpc::ServerContext* context, " + "::grpc::ServerUnaryStreamer< " + "$Request$,$Response$>* server_unary_streamer)" " = 0;\n"); printer->Outdent(); printer->Print(*vars, "};\n"); @@ -822,17 +823,18 @@ void PrintHeaderService(Printer *printer, const Service *service, PrintHeaderServerMethodGeneric(printer, service->method(i).get(), vars); } - // Server side - FC Unary + // Server side - Streamed Unary for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); - PrintHeaderServerMethodFCUnary(printer, service->method(i).get(), vars); + PrintHeaderServerMethodStreamedUnary(printer, service->method(i).get(), + vars); } printer->Print("typedef "); for (int i = 0; i < service->method_count(); ++i) { (*vars)["method_name"] = service->method(i).get()->name(); if (service->method(i)->NoStreaming()) { - printer->Print(*vars, "WithFCUnaryMethod_$method_name$<"); + printer->Print(*vars, "WithStreamedUnaryMethod_$method_name$<"); } } printer->Print("Service"); @@ -841,7 +843,7 @@ void PrintHeaderService(Printer *printer, const Service *service, printer->Print(" >"); } } - printer->Print(" FCUnaryService;\n"); + printer->Print(" StreamedUnaryService;\n"); printer->Outdent(); printer->Print("};\n"); @@ -943,9 +945,9 @@ grpc::string GetSourceIncludes(File *file, const Parameters ¶ms) { "grpc++/impl/codegen/async_unary_call.h", "grpc++/impl/codegen/channel_interface.h", "grpc++/impl/codegen/client_unary_call.h", - "grpc++/impl/codegen/fc_unary.h", "grpc++/impl/codegen/method_handler_impl.h", "grpc++/impl/codegen/rpc_service_method.h", + "grpc++/impl/codegen/server_streamed_unary.h", "grpc++/impl/codegen/service_type.h", "grpc++/impl/codegen/sync_stream.h"}; std::vector headers(headers_strs, array_end(headers_strs)); diff --git a/src/cpp/ext/reflection.grpc.pb.cc b/src/cpp/ext/reflection.grpc.pb.cc index f4a0b97d65d..6603eadc4ee 100644 --- a/src/cpp/ext/reflection.grpc.pb.cc +++ b/src/cpp/ext/reflection.grpc.pb.cc @@ -43,9 +43,9 @@ #include #include #include -#include #include #include +#include #include #include namespace grpc { diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index 1512e99a3c2..eb7125cb040 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -421,31 +421,33 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) { request_stream_handler_thread.join(); } -// Add a second service with one sync FCUnary method. -class FCUnaryDupPkg : public duplicate::EchoTestService::WithFCUnaryMethod_Echo< +// Add a second service with one sync streamed unary method. +class StreamedUnaryDupPkg : public + duplicate::EchoTestService::WithStreamedUnaryMethod_Echo< TestServiceImplDupPkg> { public: - Status FCEcho(ServerContext* context, - FCUnary* fc_unary) GRPC_OVERRIDE { + Status StreamedEcho(ServerContext* context, + ServerUnaryStreamer* stream) + GRPC_OVERRIDE { EchoRequest req; EchoResponse resp; uint32_t next_msg_sz; - fc_unary->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", next_msg_sz); - GPR_ASSERT(fc_unary->Read(&req)); + stream->NextMessageSize(&next_msg_sz); + gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); + GPR_ASSERT(stream->Read(&req)); resp.set_message(req.message() + "_dup"); - GPR_ASSERT(fc_unary->Write(resp)); + GPR_ASSERT(stream->Write(resp)); return Status::OK; } }; TEST_F(HybridEnd2endTest, - AsyncRequestStreamResponseStream_SyncFCUnaryDupService) { + AsyncRequestStreamResponseStream_SyncStreamedUnaryDupService) { typedef EchoTestService::WithAsyncMethod_RequestStream< EchoTestService::WithAsyncMethod_ResponseStream> SType; SType service; - FCUnaryDupPkg dup_service; + StreamedUnaryDupPkg dup_service; SetUpServer(&service, &dup_service, nullptr, 8192); ResetStub(); std::thread response_stream_handler_thread(HandleServerStreaming, @@ -458,30 +460,31 @@ TEST_F(HybridEnd2endTest, request_stream_handler_thread.join(); } -// Add a second service that is fully FCUnary -class FullyFCUnaryDupPkg : public duplicate::EchoTestService::FCUnaryService { +// Add a second service that is fully Streamed Unary +class FullyStreamedUnaryDupPkg : public duplicate::EchoTestService::StreamedUnaryService { public: - Status FCEcho(ServerContext* context, - FCUnary* fc_unary) GRPC_OVERRIDE { + Status StreamedEcho(ServerContext* context, + ServerUnaryStreamer* stream) + GRPC_OVERRIDE { EchoRequest req; EchoResponse resp; uint32_t next_msg_sz; - fc_unary->NextMessageSize(&next_msg_sz); - gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", next_msg_sz); - GPR_ASSERT(fc_unary->Read(&req)); + stream->NextMessageSize(&next_msg_sz); + gpr_log(GPR_INFO, "Streamed Unary Next Message Size is %u", next_msg_sz); + GPR_ASSERT(stream->Read(&req)); resp.set_message(req.message() + "_dup"); - GPR_ASSERT(fc_unary->Write(resp)); + GPR_ASSERT(stream->Write(resp)); return Status::OK; } }; TEST_F(HybridEnd2endTest, - AsyncRequestStreamResponseStream_SyncFullyFCUnaryDupService) { + AsyncRequestStreamResponseStream_SyncFullyStreamedUnaryDupService) { typedef EchoTestService::WithAsyncMethod_RequestStream< EchoTestService::WithAsyncMethod_ResponseStream> SType; SType service; - FullyFCUnaryDupPkg dup_service; + FullyStreamedUnaryDupPkg dup_service; SetUpServer(&service, &dup_service, nullptr, 8192); ResetStub(); std::thread response_stream_handler_thread(HandleServerStreaming, From d4d5f4cd53a74f7618f720bffa176b05834eb3ac Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 29 Aug 2016 16:59:21 -0700 Subject: [PATCH 21/31] clang-format --- .../grpc++/impl/codegen/method_handler_impl.h | 48 ++++++++++++------- include/grpc++/impl/codegen/service_type.h | 2 +- src/compiler/cpp_generator.cc | 10 ++-- test/cpp/end2end/hybrid_end2end_test.cc | 17 +++---- 4 files changed, 45 insertions(+), 32 deletions(-) diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 3a671fe830a..ef803483ea6 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -178,9 +178,8 @@ template class TemplatedBidiStreamingHandler : public MethodHandler { public: TemplatedBidiStreamingHandler( - std::function - func) - : func_(func), write_needed_(WriteNeeded) {} + std::function func) + : func_(func), write_needed_(WriteNeeded) {} void RunHandler(const HandlerParameter& param) GRPC_FINAL { Streamer stream(param.call, param.server_context); @@ -194,10 +193,10 @@ class TemplatedBidiStreamingHandler : public MethodHandler { ops.set_compression_level(param.server_context->compression_level()); } if (write_needed_ && status.ok()) { - // If we needed a write but never did one, we need to mark the - // status as a fail - status = Status(IMPROPER_IMPLEMENTATION, - "Service did not provide response message"); + // If we needed a write but never did one, we need to mark the + // status as a fail + status = Status(IMPROPER_IMPLEMENTATION, + "Service did not provide response message"); } } ops.ServerSendStatus(param.server_context->trailing_metadata_, status); @@ -206,24 +205,37 @@ class TemplatedBidiStreamingHandler : public MethodHandler { } private: - std::function - func_; + std::function func_; const bool write_needed_; }; template - class BidiStreamingHandler : public TemplatedBidiStreamingHandler, false> { +class BidiStreamingHandler + : public TemplatedBidiStreamingHandler< + ServerReaderWriter, false> { public: - BidiStreamingHandler(std::function*)> func, ServiceType* service): TemplatedBidiStreamingHandler,false>(std::bind(func, service, std::placeholders::_1, std::placeholders::_2)) {} - }; + BidiStreamingHandler( + std::function*)> + func, + ServiceType* service) + : TemplatedBidiStreamingHandler< + ServerReaderWriter, false>(std::bind( + func, service, std::placeholders::_1, std::placeholders::_2)) {} +}; - template - class StreamedUnaryHandler : public TemplatedBidiStreamingHandler, true> { +template +class StreamedUnaryHandler + : public TemplatedBidiStreamingHandler< + ServerUnaryStreamer, true> { public: - explicit StreamedUnaryHandler(std::function*)> func): TemplatedBidiStreamingHandler, true>(func) {} - }; + explicit StreamedUnaryHandler( + std::function*)> + func) + : TemplatedBidiStreamingHandler< + ServerUnaryStreamer, true>(func) {} +}; // Handle unknown method by returning UNIMPLEMENTED error. class UnknownMethodHandler : public MethodHandler { diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h index 9d2a80cbc43..72b22253128 100644 --- a/include/grpc++/impl/codegen/service_type.h +++ b/include/grpc++/impl/codegen/service_type.h @@ -148,7 +148,7 @@ class Service { } void MarkMethodStreamedUnary(int index, - MethodHandler* streamed_unary_method) { + MethodHandler* streamed_unary_method) { GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() && "Cannot mark an async or generic method Streamed Unary"); methods_[index]->SetHandler(streamed_unary_method); diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 7c70567d120..744d3d62e86 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -616,7 +616,7 @@ void PrintHeaderServerMethodStreamedUnary( printer->Print(*vars, "template \n"); printer->Print(*vars, "class WithStreamedUnaryMethod_$Method$ : " - "public BaseClass {\n"); + "public BaseClass {\n"); printer->Print( " private:\n" " void BaseClassMustBeDerivedFromService(const Service *service) " @@ -628,9 +628,9 @@ void PrintHeaderServerMethodStreamedUnary( " ::grpc::Service::MarkMethodStreamedUnary($Idx$,\n" " new ::grpc::StreamedUnaryHandler<$Request$, " "$Response$>(std::bind" - "(&WithStreamedUnaryMethod_$Method$::" + "(&WithStreamedUnaryMethod_$Method$::" "Streamed$Method$, this, std::placeholders::_1, " - "std::placeholders::_2)));\n" + "std::placeholders::_2)));\n" "}\n"); printer->Print(*vars, "~WithStreamedUnaryMethod_$Method$() GRPC_OVERRIDE {\n" @@ -649,7 +649,7 @@ void PrintHeaderServerMethodStreamedUnary( "// replace default version of method with streamed unary\n" "virtual ::grpc::Status Streamed$Method$(" "::grpc::ServerContext* context, " - "::grpc::ServerUnaryStreamer< " + "::grpc::ServerUnaryStreamer< " "$Request$,$Response$>* server_unary_streamer)" " = 0;\n"); printer->Outdent(); @@ -827,7 +827,7 @@ void PrintHeaderService(Printer *printer, const Service *service, for (int i = 0; i < service->method_count(); ++i) { (*vars)["Idx"] = as_string(i); PrintHeaderServerMethodStreamedUnary(printer, service->method(i).get(), - vars); + vars); } printer->Print("typedef "); diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index eb7125cb040..a6ea13aa8bd 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -422,13 +422,13 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncDupService) { } // Add a second service with one sync streamed unary method. -class StreamedUnaryDupPkg : public - duplicate::EchoTestService::WithStreamedUnaryMethod_Echo< - TestServiceImplDupPkg> { +class StreamedUnaryDupPkg + : public duplicate::EchoTestService::WithStreamedUnaryMethod_Echo< + TestServiceImplDupPkg> { public: Status StreamedEcho(ServerContext* context, - ServerUnaryStreamer* stream) - GRPC_OVERRIDE { + ServerUnaryStreamer* stream) + GRPC_OVERRIDE { EchoRequest req; EchoResponse resp; uint32_t next_msg_sz; @@ -461,11 +461,12 @@ TEST_F(HybridEnd2endTest, } // Add a second service that is fully Streamed Unary -class FullyStreamedUnaryDupPkg : public duplicate::EchoTestService::StreamedUnaryService { +class FullyStreamedUnaryDupPkg + : public duplicate::EchoTestService::StreamedUnaryService { public: Status StreamedEcho(ServerContext* context, - ServerUnaryStreamer* stream) - GRPC_OVERRIDE { + ServerUnaryStreamer* stream) + GRPC_OVERRIDE { EchoRequest req; EchoResponse resp; uint32_t next_msg_sz; From 48c9ca2bf19a05d025cf1671d16cf6b1e98e616f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 29 Aug 2016 17:10:18 -0700 Subject: [PATCH 22/31] Update golden file --- test/cpp/codegen/compiler_test_golden | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 47519289450..e5ddca41d86 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -43,10 +43,10 @@ #include #include -#include #include #include #include +#include #include #include #include @@ -209,15 +209,15 @@ class ServiceA GRPC_FINAL { } }; template - class WithFCUnaryMethod_MethodA1 : public BaseClass { + class WithStreamedUnaryMethod_MethodA1 : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service *service) {} public: - WithFCUnaryMethod_MethodA1() { - ::grpc::Service::MarkMethodFCUnary(0, - new ::grpc::FCUnaryMethodHandler(std::bind(&WithFCUnaryMethod_MethodA1::FCMethodA1, this, std::placeholders::_1, std::placeholders::_2))); + WithStreamedUnaryMethod_MethodA1() { + ::grpc::Service::MarkMethodStreamedUnary(0, + new ::grpc::StreamedUnaryHandler<::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodA1::StreamedMethodA1, this, std::placeholders::_1, std::placeholders::_2))); } - ~WithFCUnaryMethod_MethodA1() GRPC_OVERRIDE { + ~WithStreamedUnaryMethod_MethodA1() GRPC_OVERRIDE { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method @@ -225,10 +225,10 @@ class ServiceA GRPC_FINAL { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - // replace default version of this method with FCUnary - virtual ::grpc::Status FCMethodA1(::grpc::ServerContext* context, ::grpc::FCUnary< ::grpc::testing::Request,::grpc::testing::Response>* fc_unary) = 0; + // replace default version of method with streamed unary + virtual ::grpc::Status StreamedMethodA1(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpc::testing::Request,::grpc::testing::Response>* server_unary_streamer) = 0; }; - typedef WithFCUnaryMethod_MethodA1 FCUnaryService; + typedef WithStreamedUnaryMethod_MethodA1 StreamedUnaryService; }; // ServiceB leading comment 1 @@ -308,15 +308,15 @@ class ServiceB GRPC_FINAL { } }; template - class WithFCUnaryMethod_MethodB1 : public BaseClass { + class WithStreamedUnaryMethod_MethodB1 : public BaseClass { private: void BaseClassMustBeDerivedFromService(const Service *service) {} public: - WithFCUnaryMethod_MethodB1() { - ::grpc::Service::MarkMethodFCUnary(0, - new ::grpc::FCUnaryMethodHandler(std::bind(&WithFCUnaryMethod_MethodB1::FCMethodB1, this, std::placeholders::_1, std::placeholders::_2))); + WithStreamedUnaryMethod_MethodB1() { + ::grpc::Service::MarkMethodStreamedUnary(0, + new ::grpc::StreamedUnaryHandler<::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodB1::StreamedMethodB1, this, std::placeholders::_1, std::placeholders::_2))); } - ~WithFCUnaryMethod_MethodB1() GRPC_OVERRIDE { + ~WithStreamedUnaryMethod_MethodB1() GRPC_OVERRIDE { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method @@ -324,10 +324,10 @@ class ServiceB GRPC_FINAL { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - // replace default version of this method with FCUnary - virtual ::grpc::Status FCMethodB1(::grpc::ServerContext* context, ::grpc::FCUnary< ::grpc::testing::Request,::grpc::testing::Response>* fc_unary) = 0; + // replace default version of method with streamed unary + virtual ::grpc::Status StreamedMethodB1(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpc::testing::Request,::grpc::testing::Response>* server_unary_streamer) = 0; }; - typedef WithFCUnaryMethod_MethodB1 FCUnaryService; + typedef WithStreamedUnaryMethod_MethodB1 StreamedUnaryService; }; // ServiceB trailing comment 1 From 1ce6d33669fd1978f70e5aecb4ccb59fd0d5b2db Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 29 Aug 2016 17:14:27 -0700 Subject: [PATCH 23/31] Fix file names --- BUILD | 10 +++++----- CMakeLists.txt | 10 +++++----- Makefile | 12 ++++++------ build.yaml | 4 ++-- tools/doxygen/Doxyfile.c++ | 4 ++-- tools/doxygen/Doxyfile.c++.internal | 4 ++-- tools/run_tests/sources_and_headers.json | 8 ++++---- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 4 ++-- vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 8 ++++---- .../grpc++_reflection/grpc++_reflection.vcxproj | 2 +- .../grpc++_reflection.vcxproj.filters | 6 +++--- .../grpc++_test_util/grpc++_test_util.vcxproj | 2 +- .../grpc++_test_util.vcxproj.filters | 6 +++--- .../vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj | 4 ++-- .../grpc++_unsecure/grpc++_unsecure.vcxproj.filters | 8 ++++---- .../test/codegen_test_full/codegen_test_full.vcxproj | 2 +- .../codegen_test_full.vcxproj.filters | 6 +++--- .../codegen_test_minimal.vcxproj | 2 +- .../codegen_test_minimal.vcxproj.filters | 6 +++--- .../test/grpc_tool_test/grpc_tool_test.vcxproj | 1 + .../grpc_tool_test/grpc_tool_test.vcxproj.filters | 3 +++ 21 files changed, 58 insertions(+), 54 deletions(-) diff --git a/BUILD b/BUILD index e97d33d6300..8e8ec38dce0 100644 --- a/BUILD +++ b/BUILD @@ -1502,7 +1502,7 @@ cc_library( "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/fc_unary.h", + "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -1550,7 +1550,6 @@ cc_library( "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", - "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -1559,6 +1558,7 @@ cc_library( "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", + "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", @@ -1610,7 +1610,6 @@ cc_library( "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", - "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -1619,6 +1618,7 @@ cc_library( "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", + "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", @@ -1910,7 +1910,7 @@ cc_library( "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/fc_unary.h", + "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -1958,7 +1958,6 @@ cc_library( "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", - "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -1967,6 +1966,7 @@ cc_library( "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", + "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 43226e4c4b7..828c18fbac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1188,7 +1188,7 @@ foreach(_hdr include/grpc++/support/byte_buffer.h include/grpc++/support/channel_arguments.h include/grpc++/support/config.h - include/grpc++/support/fc_unary.h + include/grpc++/support/server_streamed_unary.h include/grpc++/support/slice.h include/grpc++/support/status.h include/grpc++/support/status_code_enum.h @@ -1236,7 +1236,6 @@ foreach(_hdr include/grpc++/impl/codegen/config.h include/grpc++/impl/codegen/core_codegen_interface.h include/grpc++/impl/codegen/create_auth_context.h - include/grpc++/impl/codegen/fc_unary.h include/grpc++/impl/codegen/grpc_library.h include/grpc++/impl/codegen/method_handler_impl.h include/grpc++/impl/codegen/rpc_method.h @@ -1245,6 +1244,7 @@ foreach(_hdr include/grpc++/impl/codegen/serialization_traits.h include/grpc++/impl/codegen/server_context.h include/grpc++/impl/codegen/server_interface.h + include/grpc++/impl/codegen/server_streamed_unary.h include/grpc++/impl/codegen/service_type.h include/grpc++/impl/codegen/status.h include/grpc++/impl/codegen/status_code_enum.h @@ -1310,7 +1310,6 @@ foreach(_hdr include/grpc++/impl/codegen/config.h include/grpc++/impl/codegen/core_codegen_interface.h include/grpc++/impl/codegen/create_auth_context.h - include/grpc++/impl/codegen/fc_unary.h include/grpc++/impl/codegen/grpc_library.h include/grpc++/impl/codegen/method_handler_impl.h include/grpc++/impl/codegen/rpc_method.h @@ -1319,6 +1318,7 @@ foreach(_hdr include/grpc++/impl/codegen/serialization_traits.h include/grpc++/impl/codegen/server_context.h include/grpc++/impl/codegen/server_interface.h + include/grpc++/impl/codegen/server_streamed_unary.h include/grpc++/impl/codegen/service_type.h include/grpc++/impl/codegen/status.h include/grpc++/impl/codegen/status_code_enum.h @@ -1547,7 +1547,7 @@ foreach(_hdr include/grpc++/support/byte_buffer.h include/grpc++/support/channel_arguments.h include/grpc++/support/config.h - include/grpc++/support/fc_unary.h + include/grpc++/support/server_streamed_unary.h include/grpc++/support/slice.h include/grpc++/support/status.h include/grpc++/support/status_code_enum.h @@ -1595,7 +1595,6 @@ foreach(_hdr include/grpc++/impl/codegen/config.h include/grpc++/impl/codegen/core_codegen_interface.h include/grpc++/impl/codegen/create_auth_context.h - include/grpc++/impl/codegen/fc_unary.h include/grpc++/impl/codegen/grpc_library.h include/grpc++/impl/codegen/method_handler_impl.h include/grpc++/impl/codegen/rpc_method.h @@ -1604,6 +1603,7 @@ foreach(_hdr include/grpc++/impl/codegen/serialization_traits.h include/grpc++/impl/codegen/server_context.h include/grpc++/impl/codegen/server_interface.h + include/grpc++/impl/codegen/server_streamed_unary.h include/grpc++/impl/codegen/service_type.h include/grpc++/impl/codegen/status.h include/grpc++/impl/codegen/status_code_enum.h diff --git a/Makefile b/Makefile index 51e503b347c..d673f08a465 100644 --- a/Makefile +++ b/Makefile @@ -3714,7 +3714,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ - include/grpc++/support/fc_unary.h \ + include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -3762,7 +3762,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ - include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -3771,6 +3770,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ + include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ @@ -3868,7 +3868,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ - include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -3877,6 +3876,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ + include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ @@ -4096,7 +4096,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ - include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -4105,6 +4104,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ + include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ @@ -4353,7 +4353,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ - include/grpc++/support/fc_unary.h \ + include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -4401,7 +4401,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ - include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -4410,6 +4409,7 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ + include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ diff --git a/build.yaml b/build.yaml index 897ed1816eb..2da916218f2 100644 --- a/build.yaml +++ b/build.yaml @@ -683,7 +683,7 @@ filegroups: - include/grpc++/support/byte_buffer.h - include/grpc++/support/channel_arguments.h - include/grpc++/support/config.h - - include/grpc++/support/fc_unary.h + - include/grpc++/support/server_streamed_unary.h - include/grpc++/support/slice.h - include/grpc++/support/status.h - include/grpc++/support/status_code_enum.h @@ -742,7 +742,6 @@ filegroups: - include/grpc++/impl/codegen/config.h - include/grpc++/impl/codegen/core_codegen_interface.h - include/grpc++/impl/codegen/create_auth_context.h - - include/grpc++/impl/codegen/fc_unary.h - include/grpc++/impl/codegen/grpc_library.h - include/grpc++/impl/codegen/method_handler_impl.h - include/grpc++/impl/codegen/rpc_method.h @@ -751,6 +750,7 @@ filegroups: - include/grpc++/impl/codegen/serialization_traits.h - include/grpc++/impl/codegen/server_context.h - include/grpc++/impl/codegen/server_interface.h + - include/grpc++/impl/codegen/server_streamed_unary.h - include/grpc++/impl/codegen/service_type.h - include/grpc++/impl/codegen/status.h - include/grpc++/impl/codegen/status_code_enum.h diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index c32cd125942..63e862e67c7 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -800,7 +800,7 @@ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ -include/grpc++/support/fc_unary.h \ +include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -848,7 +848,6 @@ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ -include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -857,6 +856,7 @@ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ +include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 321810774ac..ab6945fd612 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -800,7 +800,7 @@ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ -include/grpc++/support/fc_unary.h \ +include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -848,7 +848,6 @@ include/grpc++/impl/codegen/completion_queue_tag.h \ include/grpc++/impl/codegen/config.h \ include/grpc++/impl/codegen/core_codegen_interface.h \ include/grpc++/impl/codegen/create_auth_context.h \ -include/grpc++/impl/codegen/fc_unary.h \ include/grpc++/impl/codegen/grpc_library.h \ include/grpc++/impl/codegen/method_handler_impl.h \ include/grpc++/impl/codegen/rpc_method.h \ @@ -857,6 +856,7 @@ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ +include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index d2b5245c855..cb244c68ac8 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6676,7 +6676,7 @@ "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/fc_unary.h", + "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -6732,7 +6732,7 @@ "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/fc_unary.h", + "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -6792,7 +6792,6 @@ "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", - "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -6801,6 +6800,7 @@ "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", + "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", @@ -6827,7 +6827,6 @@ "include/grpc++/impl/codegen/config.h", "include/grpc++/impl/codegen/core_codegen_interface.h", "include/grpc++/impl/codegen/create_auth_context.h", - "include/grpc++/impl/codegen/fc_unary.h", "include/grpc++/impl/codegen/grpc_library.h", "include/grpc++/impl/codegen/method_handler_impl.h", "include/grpc++/impl/codegen/rpc_method.h", @@ -6836,6 +6835,7 @@ "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", + "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index 347dc308cb6..46b6935b83f 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -298,7 +298,7 @@ - + @@ -346,7 +346,6 @@ - @@ -355,6 +354,7 @@ + diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 0579fa3dbf1..890e16316ed 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -492,7 +492,7 @@ include\grpc++\support - + include\grpc++\support @@ -636,9 +636,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen @@ -663,6 +660,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj index e7f504fc2b6..638fd45bd2c 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj @@ -163,7 +163,6 @@ - @@ -172,6 +171,7 @@ + diff --git a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters index edc8866420d..078bb75cbe5 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters @@ -63,9 +63,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen @@ -90,6 +87,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj index 56dbd02873c..57f5c3d777c 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj @@ -159,7 +159,6 @@ - @@ -168,6 +167,7 @@ + diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters index 87e9f16fc9e..3e6bb0d5dd7 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters @@ -69,9 +69,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen @@ -96,6 +93,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index 84c354e81a0..ff284ff960e 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -298,7 +298,7 @@ - + @@ -346,7 +346,6 @@ - @@ -355,6 +354,7 @@ + diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index b35845dd632..e50351909d1 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -477,7 +477,7 @@ include\grpc++\support - + include\grpc++\support @@ -621,9 +621,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen @@ -648,6 +645,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj index 0e2b0d8adb3..55abe2d0104 100644 --- a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj @@ -172,7 +172,6 @@ - @@ -181,6 +180,7 @@ + diff --git a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters index 098c89cdcc6..47f337e0465 100644 --- a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters +++ b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters @@ -57,9 +57,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen @@ -84,6 +81,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj index d5133f72388..85e453c80ce 100644 --- a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj @@ -172,7 +172,6 @@ - @@ -181,6 +180,7 @@ + diff --git a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters index e4e68de1856..2fbf907b9e1 100644 --- a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters +++ b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters @@ -60,9 +60,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen @@ -87,6 +84,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj index c6f65aa30b8..269ff89b8d4 100644 --- a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj +++ b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj @@ -181,6 +181,7 @@ + diff --git a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters index 731eb2e6ffb..8c80cdda594 100644 --- a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters +++ b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters @@ -78,6 +78,9 @@ include\grpc++\impl\codegen + + include\grpc++\impl\codegen + include\grpc++\impl\codegen From d05cad245a22932de3eb411150ff232445b06130 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 10:22:06 -0700 Subject: [PATCH 24/31] Fix golden test --- test/cpp/codegen/compiler_test_golden | 1 - 1 file changed, 1 deletion(-) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index e5ddca41d86..c33f4684362 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include From 45c6d5ca641960a813b96d5acb40aa9038e1243a Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 10:23:29 -0700 Subject: [PATCH 25/31] Remove server_streamed_unary.h --- BUILD | 5 ----- CMakeLists.txt | 5 ----- Makefile | 6 ------ build.yaml | 2 -- tools/doxygen/Doxyfile.c++ | 2 -- tools/doxygen/Doxyfile.c++.internal | 2 -- tools/run_tests/sources_and_headers.json | 4 ---- vsprojects/vcxproj/grpc++/grpc++.vcxproj | 2 -- vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 6 ------ .../vcxproj/grpc++_reflection/grpc++_reflection.vcxproj | 1 - .../grpc++_reflection/grpc++_reflection.vcxproj.filters | 3 --- .../vcxproj/grpc++_test_util/grpc++_test_util.vcxproj | 1 - .../grpc++_test_util/grpc++_test_util.vcxproj.filters | 3 --- vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj | 2 -- .../vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters | 6 ------ .../test/codegen_test_full/codegen_test_full.vcxproj | 1 - .../codegen_test_full/codegen_test_full.vcxproj.filters | 3 --- .../test/codegen_test_minimal/codegen_test_minimal.vcxproj | 1 - .../codegen_test_minimal.vcxproj.filters | 3 --- .../vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj | 1 - .../test/grpc_tool_test/grpc_tool_test.vcxproj.filters | 3 --- 21 files changed, 62 deletions(-) diff --git a/BUILD b/BUILD index 82425675d2d..7dc5b6ca398 100644 --- a/BUILD +++ b/BUILD @@ -1502,7 +1502,6 @@ cc_library( "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -1558,7 +1557,6 @@ cc_library( "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", - "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", @@ -1618,7 +1616,6 @@ cc_library( "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", - "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", @@ -1910,7 +1907,6 @@ cc_library( "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -1966,7 +1962,6 @@ cc_library( "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", - "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 715e50d2cca..b8194652519 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1188,7 +1188,6 @@ foreach(_hdr include/grpc++/support/byte_buffer.h include/grpc++/support/channel_arguments.h include/grpc++/support/config.h - include/grpc++/support/server_streamed_unary.h include/grpc++/support/slice.h include/grpc++/support/status.h include/grpc++/support/status_code_enum.h @@ -1244,7 +1243,6 @@ foreach(_hdr include/grpc++/impl/codegen/serialization_traits.h include/grpc++/impl/codegen/server_context.h include/grpc++/impl/codegen/server_interface.h - include/grpc++/impl/codegen/server_streamed_unary.h include/grpc++/impl/codegen/service_type.h include/grpc++/impl/codegen/status.h include/grpc++/impl/codegen/status_code_enum.h @@ -1318,7 +1316,6 @@ foreach(_hdr include/grpc++/impl/codegen/serialization_traits.h include/grpc++/impl/codegen/server_context.h include/grpc++/impl/codegen/server_interface.h - include/grpc++/impl/codegen/server_streamed_unary.h include/grpc++/impl/codegen/service_type.h include/grpc++/impl/codegen/status.h include/grpc++/impl/codegen/status_code_enum.h @@ -1547,7 +1544,6 @@ foreach(_hdr include/grpc++/support/byte_buffer.h include/grpc++/support/channel_arguments.h include/grpc++/support/config.h - include/grpc++/support/server_streamed_unary.h include/grpc++/support/slice.h include/grpc++/support/status.h include/grpc++/support/status_code_enum.h @@ -1603,7 +1599,6 @@ foreach(_hdr include/grpc++/impl/codegen/serialization_traits.h include/grpc++/impl/codegen/server_context.h include/grpc++/impl/codegen/server_interface.h - include/grpc++/impl/codegen/server_streamed_unary.h include/grpc++/impl/codegen/service_type.h include/grpc++/impl/codegen/status.h include/grpc++/impl/codegen/status_code_enum.h diff --git a/Makefile b/Makefile index 5ce6283da83..4bd4c306c17 100644 --- a/Makefile +++ b/Makefile @@ -3714,7 +3714,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ - include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -3770,7 +3769,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ - include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ @@ -3876,7 +3874,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ - include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ @@ -4104,7 +4101,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ - include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ @@ -4353,7 +4349,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ - include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -4409,7 +4404,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ - include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ diff --git a/build.yaml b/build.yaml index 41275a6b64f..9b182d2ffcf 100644 --- a/build.yaml +++ b/build.yaml @@ -689,7 +689,6 @@ filegroups: - include/grpc++/support/byte_buffer.h - include/grpc++/support/channel_arguments.h - include/grpc++/support/config.h - - include/grpc++/support/server_streamed_unary.h - include/grpc++/support/slice.h - include/grpc++/support/status.h - include/grpc++/support/status_code_enum.h @@ -756,7 +755,6 @@ filegroups: - include/grpc++/impl/codegen/serialization_traits.h - include/grpc++/impl/codegen/server_context.h - include/grpc++/impl/codegen/server_interface.h - - include/grpc++/impl/codegen/server_streamed_unary.h - include/grpc++/impl/codegen/service_type.h - include/grpc++/impl/codegen/status.h - include/grpc++/impl/codegen/status_code_enum.h diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index 63e862e67c7..314a42d9893 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -800,7 +800,6 @@ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ -include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -856,7 +855,6 @@ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ -include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index ab6945fd612..12eb6513848 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -800,7 +800,6 @@ include/grpc++/support/async_unary_call.h \ include/grpc++/support/byte_buffer.h \ include/grpc++/support/channel_arguments.h \ include/grpc++/support/config.h \ -include/grpc++/support/server_streamed_unary.h \ include/grpc++/support/slice.h \ include/grpc++/support/status.h \ include/grpc++/support/status_code_enum.h \ @@ -856,7 +855,6 @@ include/grpc++/impl/codegen/security/auth_context.h \ include/grpc++/impl/codegen/serialization_traits.h \ include/grpc++/impl/codegen/server_context.h \ include/grpc++/impl/codegen/server_interface.h \ -include/grpc++/impl/codegen/server_streamed_unary.h \ include/grpc++/impl/codegen/service_type.h \ include/grpc++/impl/codegen/status.h \ include/grpc++/impl/codegen/status_code_enum.h \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 074ebeaf3d4..ce94c5d5e89 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6676,7 +6676,6 @@ "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -6732,7 +6731,6 @@ "include/grpc++/support/byte_buffer.h", "include/grpc++/support/channel_arguments.h", "include/grpc++/support/config.h", - "include/grpc++/support/server_streamed_unary.h", "include/grpc++/support/slice.h", "include/grpc++/support/status.h", "include/grpc++/support/status_code_enum.h", @@ -6800,7 +6798,6 @@ "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", - "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", @@ -6835,7 +6832,6 @@ "include/grpc++/impl/codegen/serialization_traits.h", "include/grpc++/impl/codegen/server_context.h", "include/grpc++/impl/codegen/server_interface.h", - "include/grpc++/impl/codegen/server_streamed_unary.h", "include/grpc++/impl/codegen/service_type.h", "include/grpc++/impl/codegen/status.h", "include/grpc++/impl/codegen/status_code_enum.h", diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index 46b6935b83f..321a403c497 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -298,7 +298,6 @@ - @@ -354,7 +353,6 @@ - diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index 890e16316ed..b34ca03a535 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -492,9 +492,6 @@ include\grpc++\support - - include\grpc++\support - include\grpc++\support @@ -660,9 +657,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj index 638fd45bd2c..7c3e63b2084 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj @@ -171,7 +171,6 @@ - diff --git a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters index 078bb75cbe5..d9cd49cc306 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters @@ -87,9 +87,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj index 57f5c3d777c..c2c7d00a6d9 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj @@ -167,7 +167,6 @@ - diff --git a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters index 3e6bb0d5dd7..9b8c8ddfada 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters @@ -93,9 +93,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj index ff284ff960e..a7bb3ef23d1 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -298,7 +298,6 @@ - @@ -354,7 +353,6 @@ - diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index e50351909d1..4ad0ae31d93 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -477,9 +477,6 @@ include\grpc++\support - - include\grpc++\support - include\grpc++\support @@ -645,9 +642,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj index 55abe2d0104..e608f7ed3a3 100644 --- a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj @@ -180,7 +180,6 @@ - diff --git a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters index 47f337e0465..8fc8f3901b3 100644 --- a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters +++ b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj.filters @@ -81,9 +81,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj index 85e453c80ce..3331c618473 100644 --- a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj @@ -180,7 +180,6 @@ - diff --git a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters index 2fbf907b9e1..a8ff1153177 100644 --- a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters +++ b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj.filters @@ -84,9 +84,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen diff --git a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj index 269ff89b8d4..c6f65aa30b8 100644 --- a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj +++ b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj @@ -181,7 +181,6 @@ - diff --git a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters index 8c80cdda594..731eb2e6ffb 100644 --- a/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters +++ b/vsprojects/vcxproj/test/grpc_tool_test/grpc_tool_test.vcxproj.filters @@ -78,9 +78,6 @@ include\grpc++\impl\codegen - - include\grpc++\impl\codegen - include\grpc++\impl\codegen From 77073ce99fae96f736d5df033c581ad6a1bc6804 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 10:26:30 -0700 Subject: [PATCH 26/31] clang-format --- include/grpc++/impl/codegen/sync_stream.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index 5c775ec957d..e1d4660ae77 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -457,7 +457,8 @@ namespace internal { template class ServerReaderWriterBody GRPC_FINAL { public: - ServerReaderWriterBody(Call* call, ServerContext* ctx) : call_(call), ctx_(ctx) {} + ServerReaderWriterBody(Call* call, ServerContext* ctx) + : call_(call), ctx_(ctx) {} void SendInitialMetadata() { GPR_CODEGEN_ASSERT(!ctx_->sent_initial_metadata_); @@ -512,8 +513,7 @@ class ServerReaderWriterBody GRPC_FINAL { template class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface { public: - ServerReaderWriter(Call* call, ServerContext* ctx) - : body_(call, ctx) {} + ServerReaderWriter(Call* call, ServerContext* ctx) : body_(call, ctx) {} void SendInitialMetadata() GRPC_OVERRIDE { body_.SendInitialMetadata(); } @@ -527,9 +527,9 @@ class ServerReaderWriter GRPC_FINAL : public ServerReaderWriterInterface { bool Write(const W& msg, const WriteOptions& options) GRPC_OVERRIDE { return body_.Write(msg, options); } - + private: - internal::ServerReaderWriterBody body_; + internal::ServerReaderWriterBody body_; }; /// A class to represent a flow-controlled unary call. This is something @@ -573,7 +573,7 @@ class ServerUnaryStreamer GRPC_FINAL } private: - internal::ServerReaderWriterBody body_; + internal::ServerReaderWriterBody body_; bool read_done_; bool write_done_; }; From 5e6edbbb6966ed94455111a75f0d9a7255962d2d Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 11:43:32 -0700 Subject: [PATCH 27/31] Put a space after '<' to avoid chance of digraph --- src/compiler/cpp_generator.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 4f602f5aa81..d0c35ea1ab3 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -625,7 +625,7 @@ void PrintHeaderServerMethodStreamedUnary( printer->Print(*vars, "WithStreamedUnaryMethod_$Method$() {\n" " ::grpc::Service::MarkMethodStreamedUnary($Idx$,\n" - " new ::grpc::StreamedUnaryHandler<$Request$, " + " new ::grpc::StreamedUnaryHandler< $Request$, " "$Response$>(std::bind" "(&WithStreamedUnaryMethod_$Method$::" "Streamed$Method$, this, std::placeholders::_1, " From 2998daa81b8c5f2961bbfcf54a43a4c054371447 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 12:09:35 -0700 Subject: [PATCH 28/31] Another golden file --- include/grpc++/ext/reflection.grpc.pb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpc++/ext/reflection.grpc.pb.h b/include/grpc++/ext/reflection.grpc.pb.h index dbf93f81f35..064117e3030 100644 --- a/include/grpc++/ext/reflection.grpc.pb.h +++ b/include/grpc++/ext/reflection.grpc.pb.h @@ -175,7 +175,7 @@ class ServerReflection GRPC_FINAL { return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } }; - typedef Service FCUnaryService; + typedef Service StreamedUnaryService; }; } // namespace v1alpha From 3703ece81b236356094a1f23da1f69af48d7aa84 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 12:13:39 -0700 Subject: [PATCH 29/31] a golden file --- test/cpp/codegen/compiler_test_golden | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index c33f4684362..7b0fd6ce804 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -214,7 +214,7 @@ class ServiceA GRPC_FINAL { public: WithStreamedUnaryMethod_MethodA1() { ::grpc::Service::MarkMethodStreamedUnary(0, - new ::grpc::StreamedUnaryHandler<::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodA1::StreamedMethodA1, this, std::placeholders::_1, std::placeholders::_2))); + new ::grpc::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodA1::StreamedMethodA1, this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_MethodA1() GRPC_OVERRIDE { BaseClassMustBeDerivedFromService(this); @@ -313,7 +313,7 @@ class ServiceB GRPC_FINAL { public: WithStreamedUnaryMethod_MethodB1() { ::grpc::Service::MarkMethodStreamedUnary(0, - new ::grpc::StreamedUnaryHandler<::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodB1::StreamedMethodB1, this, std::placeholders::_1, std::placeholders::_2))); + new ::grpc::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodB1::StreamedMethodB1, this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_MethodB1() GRPC_OVERRIDE { BaseClassMustBeDerivedFromService(this); From 84033b1f6b34edd464be22967f23de6d07bf4316 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 20:50:43 -0700 Subject: [PATCH 30/31] Stick to StatusCode::INTERNAL when there's no service response on a StreamedUnary --- include/grpc++/impl/codegen/method_handler_impl.h | 4 ++-- include/grpc++/impl/codegen/status_code_enum.h | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 170852606f1..3f25b546daf 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -194,8 +194,8 @@ class TemplatedBidiStreamingHandler : public MethodHandler { if (write_needed_ && status.ok()) { // If we needed a write but never did one, we need to mark the // status as a fail - status = Status(IMPROPER_IMPLEMENTATION, - "Service did not provide response message"); + status = Status(StatusCode::INTERNAL, + "Service did not provide response message"); } } ops.ServerSendStatus(param.server_context->trailing_metadata_, status); diff --git a/include/grpc++/impl/codegen/status_code_enum.h b/include/grpc++/impl/codegen/status_code_enum.h index 0f18a22c366..9a90a18e2a5 100644 --- a/include/grpc++/impl/codegen/status_code_enum.h +++ b/include/grpc++/impl/codegen/status_code_enum.h @@ -143,11 +143,6 @@ enum StatusCode { /// Unrecoverable data loss or corruption. DATA_LOSS = 15, - // Service was improperly implemented, violated a gRPC API requirement - // Not quite the same as unimplemented since it could just be that the API - // requirement was violated in this particular circumstance - IMPROPER_IMPLEMENTATION = 16, - /// Force users to include a default branch: DO_NOT_USE = -1 }; From 5c9a3438c56152b33f320494bc16bdbb2acf4232 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 Aug 2016 20:52:32 -0700 Subject: [PATCH 31/31] clang-format --- include/grpc++/impl/codegen/method_handler_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 3f25b546daf..d989263252d 100644 --- a/include/grpc++/impl/codegen/method_handler_impl.h +++ b/include/grpc++/impl/codegen/method_handler_impl.h @@ -195,7 +195,7 @@ class TemplatedBidiStreamingHandler : public MethodHandler { // If we needed a write but never did one, we need to mark the // status as a fail status = Status(StatusCode::INTERNAL, - "Service did not provide response message"); + "Service did not provide response message"); } } ops.ServerSendStatus(param.server_context->trailing_metadata_, status);