From fcb98a578cb6b359e4fd26fb618578def4d8193d Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 13:18:50 -0700 Subject: Add NextMessageSize method to all readable streams as an upper-bound on the actual message size. Rename Size of FCUnary to NextMessageSize for consistency --- test/cpp/end2end/mock_test.cc | 3 +++ 1 file changed, 3 insertions(+) (limited to 'test/cpp/end2end') diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 0ace5d9418..744a7cd9eb 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_); -- cgit v1.2.3 From c0c38b1f19c98f4c21ac2b75ba968e0c3aeefd19 Mon Sep 17 00:00:00 2001 From: vjpai Date: Thu, 23 Jun 2016 17:27:11 -0700 Subject: Make the FCUnary class actually work and test it --- include/grpc++/impl/codegen/completion_queue.h | 8 +++++ include/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(-) (limited to 'test/cpp/end2end') diff --git a/include/grpc++/impl/codegen/completion_queue.h b/include/grpc++/impl/codegen/completion_queue.h index 1b84b44705..2286f01b8a 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 2a14ef3977..293ae6a4d8 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 a1e1ed176f..8a925d8037 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 da89d433b1..9b493fe926 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 7e0c0e8a7c..699cf49b26 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< -- cgit v1.2.3 From 2d04dd827ce66a54ea8ddc6c691f9c028833fd56 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 27 Jul 2016 11:35:56 -0700 Subject: 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(-) (limited to 'test/cpp/end2end') diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h index 22e40ab02e..768443912b 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 0afa8b6aa4..930c72056c 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 699cf49b26..b80010e803 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 744a7cd9eb..4052627122 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_); -- cgit v1.2.3 From c79b0650d2eccb5d1af8512c7f3178a39a3df063 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 27 Jul 2016 21:11:58 -0700 Subject: removed codegen/log.h --- BUILD | 9 -- Makefile | 8 -- build.yaml | 1 - gRPC-Core.podspec | 2 - grpc.def | 10 +- grpc.gemspec | 2 - include/grpc++/impl/codegen/async_unary_call.h | 1 - include/grpc++/impl/codegen/client_context.h | 1 - include/grpc++/impl/codegen/grpc_library.h | 1 - include/grpc++/impl/codegen/proto_utils.h | 1 - include/grpc++/impl/codegen/sync_stream.h | 1 - include/grpc/impl/codegen/log.h | 118 --------------------- include/grpc/support/log.h | 81 +++++++++++++- package.xml | 2 - src/core/lib/channel/handshaker.c | 2 +- src/cpp/client/client_context.cc | 1 + src/cpp/common/core_codegen.cc | 2 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 20 ++-- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 32 +++--- test/core/surface/public_headers_must_be_c89.c | 1 - test/cpp/end2end/client_crash_test.cc | 1 + test/cpp/end2end/client_crash_test_server.cc | 2 + test/cpp/end2end/end2end_test.cc | 1 + test/cpp/end2end/mock_test.cc | 1 + test/cpp/end2end/server_crash_test.cc | 1 + test/cpp/end2end/server_crash_test_client.cc | 2 + test/cpp/end2end/shutdown_test.cc | 4 +- test/cpp/end2end/streaming_throughput_test.cc | 4 +- test/cpp/end2end/test_service_impl.cc | 3 +- test/cpp/interop/metrics_client.cc | 1 + test/cpp/interop/stress_interop_client.cc | 1 + test/cpp/interop/stress_test.cc | 1 + test/cpp/util/metrics_server.cc | 1 + test/cpp/util/test_credentials_provider.cc | 1 + tools/doxygen/Doxyfile.c++ | 1 - tools/doxygen/Doxyfile.c++.internal | 1 - tools/doxygen/Doxyfile.core | 2 - tools/doxygen/Doxyfile.core.internal | 2 - tools/run_tests/sources_and_headers.json | 2 - vsprojects/vcxproj/gpr/gpr.vcxproj | 1 - vsprojects/vcxproj/gpr/gpr.vcxproj.filters | 3 - vsprojects/vcxproj/grpc++/grpc++.vcxproj | 1 - vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters | 3 - .../grpc++_reflection/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 | 1 - .../grpc++_unsecure.vcxproj.filters | 3 - vsprojects/vcxproj/grpc/grpc.vcxproj | 1 - vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 3 - .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 1 - .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 3 - .../codegen_test_full/codegen_test_full.vcxproj | 1 - .../codegen_test_full.vcxproj.filters | 3 - .../codegen_test_minimal.vcxproj | 1 - .../codegen_test_minimal.vcxproj.filters | 3 - 57 files changed, 135 insertions(+), 229 deletions(-) delete mode 100644 include/grpc/impl/codegen/log.h (limited to 'test/cpp/end2end') diff --git a/BUILD b/BUILD index 84ce5b2433..92f22f2084 100644 --- a/BUILD +++ b/BUILD @@ -135,7 +135,6 @@ cc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -511,7 +510,6 @@ cc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -867,7 +865,6 @@ cc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -1195,7 +1192,6 @@ cc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -1352,7 +1348,6 @@ cc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -1428,7 +1423,6 @@ cc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -1572,7 +1566,6 @@ cc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -1736,7 +1729,6 @@ objc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -1971,7 +1963,6 @@ objc_library( "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", diff --git a/Makefile b/Makefile index ddbe15da3a..04b8c642d1 100644 --- a/Makefile +++ b/Makefile @@ -2442,7 +2442,6 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -2719,7 +2718,6 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -2966,7 +2964,6 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -3298,7 +3295,6 @@ PUBLIC_HEADERS_C += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -3546,7 +3542,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -3669,7 +3664,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -3893,7 +3887,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -4073,7 +4066,6 @@ PUBLIC_HEADERS_CXX += \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ - include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ diff --git a/build.yaml b/build.yaml index eb3a39a9a5..cb7da07c37 100644 --- a/build.yaml +++ b/build.yaml @@ -131,7 +131,6 @@ filegroups: - include/grpc/impl/codegen/atm_gcc_atomic.h - include/grpc/impl/codegen/atm_gcc_sync.h - include/grpc/impl/codegen/atm_windows.h - - include/grpc/impl/codegen/log.h - include/grpc/impl/codegen/port_platform.h - include/grpc/impl/codegen/slice.h - include/grpc/impl/codegen/slice_buffer.h diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 34c385cdb8..e63829af07 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -148,7 +148,6 @@ Pod::Spec.new do |s| 'include/grpc/impl/codegen/atm_gcc_atomic.h', 'include/grpc/impl/codegen/atm_gcc_sync.h', 'include/grpc/impl/codegen/atm_windows.h', - 'include/grpc/impl/codegen/log.h', 'include/grpc/impl/codegen/port_platform.h', 'include/grpc/impl/codegen/slice.h', 'include/grpc/impl/codegen/slice_buffer.h', @@ -172,7 +171,6 @@ Pod::Spec.new do |s| 'include/grpc/impl/codegen/atm_gcc_atomic.h', 'include/grpc/impl/codegen/atm_gcc_sync.h', 'include/grpc/impl/codegen/atm_windows.h', - 'include/grpc/impl/codegen/log.h', 'include/grpc/impl/codegen/port_platform.h', 'include/grpc/impl/codegen/slice.h', 'include/grpc/impl/codegen/slice_buffer.h', diff --git a/grpc.def b/grpc.def index f264bf7624..bca8648253 100644 --- a/grpc.def +++ b/grpc.def @@ -133,11 +133,6 @@ EXPORTS grpc_server_add_secure_http2_port grpc_call_set_credentials grpc_server_credentials_set_auth_metadata_processor - gpr_log - gpr_log_message - gpr_set_log_verbosity - gpr_log_verbosity_init - gpr_set_log_function gpr_slice_ref gpr_slice_unref gpr_slice_new @@ -233,6 +228,11 @@ EXPORTS gpr_histogram_merge_contents gpr_join_host_port gpr_split_host_port + gpr_log + gpr_log_message + gpr_set_log_verbosity + gpr_log_verbosity_init + gpr_set_log_function gpr_format_message gpr_strdup gpr_asprintf diff --git a/grpc.gemspec b/grpc.gemspec index bb2070b7b3..a9f1d026e0 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -75,7 +75,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_sync.h ) s.files += %w( include/grpc/impl/codegen/atm_windows.h ) - s.files += %w( include/grpc/impl/codegen/log.h ) s.files += %w( include/grpc/impl/codegen/port_platform.h ) s.files += %w( include/grpc/impl/codegen/slice.h ) s.files += %w( include/grpc/impl/codegen/slice_buffer.h ) @@ -155,7 +154,6 @@ Gem::Specification.new do |s| s.files += %w( include/grpc/impl/codegen/atm_gcc_atomic.h ) s.files += %w( include/grpc/impl/codegen/atm_gcc_sync.h ) s.files += %w( include/grpc/impl/codegen/atm_windows.h ) - s.files += %w( include/grpc/impl/codegen/log.h ) s.files += %w( include/grpc/impl/codegen/port_platform.h ) s.files += %w( include/grpc/impl/codegen/slice.h ) s.files += %w( include/grpc/impl/codegen/slice_buffer.h ) diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h index 05681e2242..96f91eaf76 100644 --- a/include/grpc++/impl/codegen/async_unary_call.h +++ b/include/grpc++/impl/codegen/async_unary_call.h @@ -40,7 +40,6 @@ #include #include #include -#include namespace grpc { diff --git a/include/grpc++/impl/codegen/client_context.h b/include/grpc++/impl/codegen/client_context.h index d6596d402c..3467ab14c2 100644 --- a/include/grpc++/impl/codegen/client_context.h +++ b/include/grpc++/impl/codegen/client_context.h @@ -62,7 +62,6 @@ #include #include #include -#include #include struct census_context; diff --git a/include/grpc++/impl/codegen/grpc_library.h b/include/grpc++/impl/codegen/grpc_library.h index 3cdc6f3f7c..2b11aff214 100644 --- a/include/grpc++/impl/codegen/grpc_library.h +++ b/include/grpc++/impl/codegen/grpc_library.h @@ -35,7 +35,6 @@ #define GRPCXX_IMPL_CODEGEN_GRPC_LIBRARY_H #include -#include namespace grpc { diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h index 5b9551c26b..d2e0f6fcdd 100644 --- a/include/grpc++/impl/codegen/proto_utils.h +++ b/include/grpc++/impl/codegen/proto_utils.h @@ -42,7 +42,6 @@ #include #include #include -#include #include namespace grpc { diff --git a/include/grpc++/impl/codegen/sync_stream.h b/include/grpc++/impl/codegen/sync_stream.h index cbfa410699..121c84cc18 100644 --- a/include/grpc++/impl/codegen/sync_stream.h +++ b/include/grpc++/impl/codegen/sync_stream.h @@ -42,7 +42,6 @@ #include #include #include -#include namespace grpc { diff --git a/include/grpc/impl/codegen/log.h b/include/grpc/impl/codegen/log.h deleted file mode 100644 index e5010c29da..0000000000 --- a/include/grpc/impl/codegen/log.h +++ /dev/null @@ -1,118 +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. - * - */ - -#ifndef GRPC_IMPL_CODEGEN_LOG_H -#define GRPC_IMPL_CODEGEN_LOG_H - -#include -#include -#include /* for abort() */ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* GPR log API. - - Usage (within grpc): - - int argument1 = 3; - char* argument2 = "hello"; - gpr_log(GPR_DEBUG, "format string %d", argument1); - gpr_log(GPR_INFO, "hello world"); - gpr_log(GPR_ERROR, "%d %s!!", argument1, argument2); */ - -/* The severity of a log message - use the #defines below when calling into - gpr_log to additionally supply file and line data */ -typedef enum gpr_log_severity { - GPR_LOG_SEVERITY_DEBUG, - GPR_LOG_SEVERITY_INFO, - GPR_LOG_SEVERITY_ERROR -} gpr_log_severity; - -#define GPR_LOG_VERBOSITY_UNSET -1 - -/* Returns a string representation of the log severity */ -const char *gpr_log_severity_string(gpr_log_severity severity); - -/* Macros to build log contexts at various severity levels */ -#define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG -#define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO -#define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR - -/* Log a message. It's advised to use GPR_xxx above to generate the context - * for each message */ -GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, - const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5); - -GPRAPI void gpr_log_message(const char *file, int line, - gpr_log_severity severity, const char *message); - -/* Set global log verbosity */ -GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print); - -GPRAPI void gpr_log_verbosity_init(); - -/* Log overrides: applications can use this API to intercept logging calls - and use their own implementations */ - -typedef struct { - const char *file; - int line; - gpr_log_severity severity; - const char *message; -} gpr_log_func_args; - -typedef void (*gpr_log_func)(gpr_log_func_args *args); -GPRAPI void gpr_set_log_function(gpr_log_func func); - -/* abort() the process if x is zero, having written a line to the log. - - Intended for internal invariants. If the error can be recovered from, - without the possibility of corruption, or might best be reflected via - an exception in a higher-level language, consider returning error code. */ -#define GPR_ASSERT(x) \ - do { \ - if (!(x)) { \ - gpr_log(GPR_ERROR, "assertion failed: %s", #x); \ - abort(); \ - } \ - } while (0) - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_IMPL_CODEGEN_LOG_H */ diff --git a/include/grpc/support/log.h b/include/grpc/support/log.h index 3fdba04943..5acf17fc2c 100644 --- a/include/grpc/support/log.h +++ b/include/grpc/support/log.h @@ -34,6 +34,85 @@ #ifndef GRPC_SUPPORT_LOG_H #define GRPC_SUPPORT_LOG_H -#include +#include +#include +#include /* for abort() */ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* GPR log API. + + Usage (within grpc): + + int argument1 = 3; + char* argument2 = "hello"; + gpr_log(GPR_DEBUG, "format string %d", argument1); + gpr_log(GPR_INFO, "hello world"); + gpr_log(GPR_ERROR, "%d %s!!", argument1, argument2); */ + +/* The severity of a log message - use the #defines below when calling into + gpr_log to additionally supply file and line data */ +typedef enum gpr_log_severity { + GPR_LOG_SEVERITY_DEBUG, + GPR_LOG_SEVERITY_INFO, + GPR_LOG_SEVERITY_ERROR +} gpr_log_severity; + +#define GPR_LOG_VERBOSITY_UNSET -1 + +/* Returns a string representation of the log severity */ +const char *gpr_log_severity_string(gpr_log_severity severity); + +/* Macros to build log contexts at various severity levels */ +#define GPR_DEBUG __FILE__, __LINE__, GPR_LOG_SEVERITY_DEBUG +#define GPR_INFO __FILE__, __LINE__, GPR_LOG_SEVERITY_INFO +#define GPR_ERROR __FILE__, __LINE__, GPR_LOG_SEVERITY_ERROR + +/* Log a message. It's advised to use GPR_xxx above to generate the context + * for each message */ +GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, + const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5); + +GPRAPI void gpr_log_message(const char *file, int line, + gpr_log_severity severity, const char *message); + +/* Set global log verbosity */ +GPRAPI void gpr_set_log_verbosity(gpr_log_severity min_severity_to_print); + +GPRAPI void gpr_log_verbosity_init(); + +/* Log overrides: applications can use this API to intercept logging calls + and use their own implementations */ + +typedef struct { + const char *file; + int line; + gpr_log_severity severity; + const char *message; +} gpr_log_func_args; + +typedef void (*gpr_log_func)(gpr_log_func_args *args); +GPRAPI void gpr_set_log_function(gpr_log_func func); + +/* abort() the process if x is zero, having written a line to the log. + + Intended for internal invariants. If the error can be recovered from, + without the possibility of corruption, or might best be reflected via + an exception in a higher-level language, consider returning error code. */ +#define GPR_ASSERT(x) \ + do { \ + if (!(x)) { \ + gpr_log(GPR_ERROR, "assertion failed: %s", #x); \ + abort(); \ + } \ + } while (0) + +#ifdef __cplusplus +} +#endif #endif /* GRPC_SUPPORT_LOG_H */ diff --git a/package.xml b/package.xml index 79f8e989a6..59f733e6da 100644 --- a/package.xml +++ b/package.xml @@ -83,7 +83,6 @@ - @@ -163,7 +162,6 @@ - diff --git a/src/core/lib/channel/handshaker.c b/src/core/lib/channel/handshaker.c index b5638e4202..1badba9069 100644 --- a/src/core/lib/channel/handshaker.c +++ b/src/core/lib/channel/handshaker.c @@ -33,8 +33,8 @@ #include -#include #include +#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/handshaker.h" diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index 0ba77a5057..20df384a6f 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc index f51e31680d..c64f6514ab 100644 --- a/src/cpp/common/core_codegen.cc +++ b/src/cpp/common/core_codegen.cc @@ -39,8 +39,8 @@ #include #include #include -#include #include +#include #include #include #include diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index e9f84fa7be..d0236f13ca 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -171,11 +171,6 @@ grpc_ssl_server_credentials_create_ex_type grpc_ssl_server_credentials_create_ex grpc_server_add_secure_http2_port_type grpc_server_add_secure_http2_port_import; grpc_call_set_credentials_type grpc_call_set_credentials_import; grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; -gpr_log_type gpr_log_import; -gpr_log_message_type gpr_log_message_import; -gpr_set_log_verbosity_type gpr_set_log_verbosity_import; -gpr_log_verbosity_init_type gpr_log_verbosity_init_import; -gpr_set_log_function_type gpr_set_log_function_import; gpr_slice_ref_type gpr_slice_ref_import; gpr_slice_unref_type gpr_slice_unref_import; gpr_slice_new_type gpr_slice_new_import; @@ -271,6 +266,11 @@ gpr_histogram_get_contents_type gpr_histogram_get_contents_import; gpr_histogram_merge_contents_type gpr_histogram_merge_contents_import; gpr_join_host_port_type gpr_join_host_port_import; gpr_split_host_port_type gpr_split_host_port_import; +gpr_log_type gpr_log_import; +gpr_log_message_type gpr_log_message_import; +gpr_set_log_verbosity_type gpr_set_log_verbosity_import; +gpr_log_verbosity_init_type gpr_log_verbosity_init_import; +gpr_set_log_function_type gpr_set_log_function_import; gpr_format_message_type gpr_format_message_import; gpr_strdup_type gpr_strdup_import; gpr_asprintf_type gpr_asprintf_import; @@ -444,11 +444,6 @@ void grpc_rb_load_imports(HMODULE library) { grpc_server_add_secure_http2_port_import = (grpc_server_add_secure_http2_port_type) GetProcAddress(library, "grpc_server_add_secure_http2_port"); grpc_call_set_credentials_import = (grpc_call_set_credentials_type) GetProcAddress(library, "grpc_call_set_credentials"); grpc_server_credentials_set_auth_metadata_processor_import = (grpc_server_credentials_set_auth_metadata_processor_type) GetProcAddress(library, "grpc_server_credentials_set_auth_metadata_processor"); - gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); - gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); - gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity"); - gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); - gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref"); gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref"); gpr_slice_new_import = (gpr_slice_new_type) GetProcAddress(library, "gpr_slice_new"); @@ -544,6 +539,11 @@ void grpc_rb_load_imports(HMODULE library) { gpr_histogram_merge_contents_import = (gpr_histogram_merge_contents_type) GetProcAddress(library, "gpr_histogram_merge_contents"); gpr_join_host_port_import = (gpr_join_host_port_type) GetProcAddress(library, "gpr_join_host_port"); gpr_split_host_port_import = (gpr_split_host_port_type) GetProcAddress(library, "gpr_split_host_port"); + gpr_log_import = (gpr_log_type) GetProcAddress(library, "gpr_log"); + gpr_log_message_import = (gpr_log_message_type) GetProcAddress(library, "gpr_log_message"); + gpr_set_log_verbosity_import = (gpr_set_log_verbosity_type) GetProcAddress(library, "gpr_set_log_verbosity"); + gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); + gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message"); gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup"); gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index fccefb44bf..f99e9c4429 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include @@ -56,6 +55,7 @@ #include #include #include +#include #include #include #include @@ -464,21 +464,6 @@ extern grpc_call_set_credentials_type grpc_call_set_credentials_import; typedef void(*grpc_server_credentials_set_auth_metadata_processor_type)(grpc_server_credentials *creds, grpc_auth_metadata_processor processor); extern grpc_server_credentials_set_auth_metadata_processor_type grpc_server_credentials_set_auth_metadata_processor_import; #define grpc_server_credentials_set_auth_metadata_processor grpc_server_credentials_set_auth_metadata_processor_import -typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5); -extern gpr_log_type gpr_log_import; -#define gpr_log gpr_log_import -typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); -extern gpr_log_message_type gpr_log_message_import; -#define gpr_log_message gpr_log_message_import -typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print); -extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import; -#define gpr_set_log_verbosity gpr_set_log_verbosity_import -typedef void(*gpr_log_verbosity_init_type)(); -extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import; -#define gpr_log_verbosity_init gpr_log_verbosity_init_import -typedef void(*gpr_set_log_function_type)(gpr_log_func func); -extern gpr_set_log_function_type gpr_set_log_function_import; -#define gpr_set_log_function gpr_set_log_function_import typedef gpr_slice(*gpr_slice_ref_type)(gpr_slice s); extern gpr_slice_ref_type gpr_slice_ref_import; #define gpr_slice_ref gpr_slice_ref_import @@ -764,6 +749,21 @@ extern gpr_join_host_port_type gpr_join_host_port_import; typedef int(*gpr_split_host_port_type)(const char *name, char **host, char **port); extern gpr_split_host_port_type gpr_split_host_port_import; #define gpr_split_host_port gpr_split_host_port_import +typedef void(*gpr_log_type)(const char *file, int line, gpr_log_severity severity, const char *format, ...) GPRC_PRINT_FORMAT_CHECK(4, 5); +extern gpr_log_type gpr_log_import; +#define gpr_log gpr_log_import +typedef void(*gpr_log_message_type)(const char *file, int line, gpr_log_severity severity, const char *message); +extern gpr_log_message_type gpr_log_message_import; +#define gpr_log_message gpr_log_message_import +typedef void(*gpr_set_log_verbosity_type)(gpr_log_severity min_severity_to_print); +extern gpr_set_log_verbosity_type gpr_set_log_verbosity_import; +#define gpr_set_log_verbosity gpr_set_log_verbosity_import +typedef void(*gpr_log_verbosity_init_type)(); +extern gpr_log_verbosity_init_type gpr_log_verbosity_init_import; +#define gpr_log_verbosity_init gpr_log_verbosity_init_import +typedef void(*gpr_set_log_function_type)(gpr_log_func func); +extern gpr_set_log_function_type gpr_set_log_function_import; +#define gpr_set_log_function gpr_set_log_function_import typedef char *(*gpr_format_message_type)(int messageid); extern gpr_format_message_type gpr_format_message_import; #define gpr_format_message gpr_format_message_import diff --git a/test/core/surface/public_headers_must_be_c89.c b/test/core/surface/public_headers_must_be_c89.c index ec901a1547..9eadb12aba 100644 --- a/test/core/surface/public_headers_must_be_c89.c +++ b/test/core/surface/public_headers_must_be_c89.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/test/cpp/end2end/client_crash_test.cc b/test/cpp/end2end/client_crash_test.cc index 30b04fb9b9..c452ad2beb 100644 --- a/test/cpp/end2end/client_crash_test.cc +++ b/test/cpp/end2end/client_crash_test.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/test/cpp/end2end/client_crash_test_server.cc b/test/cpp/end2end/client_crash_test_server.cc index 9568ca26be..6e1457407c 100644 --- a/test/cpp/end2end/client_crash_test_server.cc +++ b/test/cpp/end2end/client_crash_test_server.cc @@ -39,6 +39,8 @@ #include #include #include +#include + #include "src/proto/grpc/testing/echo.grpc.pb.h" DEFINE_string(address, "", "Address to bind to"); diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 46a58d3ac3..af706a90a0 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include diff --git a/test/cpp/end2end/mock_test.cc b/test/cpp/end2end/mock_test.cc index 0ace5d9418..f1e6aac36a 100644 --- a/test/cpp/end2end/mock_test.cc +++ b/test/cpp/end2end/mock_test.cc @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include diff --git a/test/cpp/end2end/server_crash_test.cc b/test/cpp/end2end/server_crash_test.cc index e447360276..16a5fa2322 100644 --- a/test/cpp/end2end/server_crash_test.cc +++ b/test/cpp/end2end/server_crash_test.cc @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include diff --git a/test/cpp/end2end/server_crash_test_client.cc b/test/cpp/end2end/server_crash_test_client.cc index ece948d5a7..10a251c952 100644 --- a/test/cpp/end2end/server_crash_test_client.cc +++ b/test/cpp/end2end/server_crash_test_client.cc @@ -40,6 +40,8 @@ #include #include #include +#include + #include "src/proto/grpc/testing/echo.grpc.pb.h" DEFINE_string(address, "", "Address to connect to"); diff --git a/test/cpp/end2end/shutdown_test.cc b/test/cpp/end2end/shutdown_test.cc index 3f98de6db7..4cba3b1c81 100644 --- a/test/cpp/end2end/shutdown_test.cc +++ b/test/cpp/end2end/shutdown_test.cc @@ -33,6 +33,8 @@ #include +#include + #include #include #include @@ -40,8 +42,8 @@ #include #include #include +#include #include -#include #include "src/core/lib/support/env.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" diff --git a/test/cpp/end2end/streaming_throughput_test.cc b/test/cpp/end2end/streaming_throughput_test.cc index 9e82c30701..fbef761ca9 100644 --- a/test/cpp/end2end/streaming_throughput_test.cc +++ b/test/cpp/end2end/streaming_throughput_test.cc @@ -35,6 +35,8 @@ #include #include +#include + #include #include #include @@ -45,9 +47,9 @@ #include #include #include +#include #include #include -#include #include "src/proto/grpc/testing/duplicate/echo_duplicate.grpc.pb.h" #include "src/proto/grpc/testing/echo.grpc.pb.h" diff --git a/test/cpp/end2end/test_service_impl.cc b/test/cpp/end2end/test_service_impl.cc index 52abd80d69..2de344efd5 100644 --- a/test/cpp/end2end/test_service_impl.cc +++ b/test/cpp/end2end/test_service_impl.cc @@ -38,7 +38,8 @@ #include #include -#include +#include + #include #include "src/proto/grpc/testing/echo.grpc.pb.h" diff --git a/test/cpp/interop/metrics_client.cc b/test/cpp/interop/metrics_client.cc index 179de30805..9d5212e9d5 100644 --- a/test/cpp/interop/metrics_client.cc +++ b/test/cpp/interop/metrics_client.cc @@ -36,6 +36,7 @@ #include #include +#include #include "src/proto/grpc/testing/metrics.grpc.pb.h" #include "src/proto/grpc/testing/metrics.pb.h" diff --git a/test/cpp/interop/stress_interop_client.cc b/test/cpp/interop/stress_interop_client.cc index 1d5fc80cf2..0ea71e4cf4 100644 --- a/test/cpp/interop/stress_interop_client.cc +++ b/test/cpp/interop/stress_interop_client.cc @@ -38,6 +38,7 @@ #include #include +#include #include "test/cpp/interop/interop_client.h" #include "test/cpp/util/metrics_server.h" diff --git a/test/cpp/interop/stress_test.cc b/test/cpp/interop/stress_test.cc index 7787931900..5647cb5531 100644 --- a/test/cpp/interop/stress_test.cc +++ b/test/cpp/interop/stress_test.cc @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "src/proto/grpc/testing/metrics.grpc.pb.h" diff --git a/test/cpp/util/metrics_server.cc b/test/cpp/util/metrics_server.cc index 1c7cd6382a..9296d6515e 100644 --- a/test/cpp/util/metrics_server.cc +++ b/test/cpp/util/metrics_server.cc @@ -35,6 +35,7 @@ #include #include +#include #include "src/proto/grpc/testing/metrics.grpc.pb.h" #include "src/proto/grpc/testing/metrics.pb.h" diff --git a/test/cpp/util/test_credentials_provider.cc b/test/cpp/util/test_credentials_provider.cc index 6e68f59e6a..ca15f29795 100644 --- a/test/cpp/util/test_credentials_provider.cc +++ b/test/cpp/util/test_credentials_provider.cc @@ -37,6 +37,7 @@ #include #include +#include #include #include "test/core/end2end/data/ssl_test_data.h" diff --git a/tools/doxygen/Doxyfile.c++ b/tools/doxygen/Doxyfile.c++ index d7eab48bda..27eecc3528 100644 --- a/tools/doxygen/Doxyfile.c++ +++ b/tools/doxygen/Doxyfile.c++ @@ -847,7 +847,6 @@ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ -include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index beab3e1e5d..bf49c0354e 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -847,7 +847,6 @@ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ -include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ diff --git a/tools/doxygen/Doxyfile.core b/tools/doxygen/Doxyfile.core index af07968f4f..2a3f200507 100644 --- a/tools/doxygen/Doxyfile.core +++ b/tools/doxygen/Doxyfile.core @@ -776,7 +776,6 @@ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ -include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -819,7 +818,6 @@ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ -include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index 9c7335946c..47b75f2b6e 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -776,7 +776,6 @@ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ -include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ @@ -1162,7 +1161,6 @@ include/grpc/impl/codegen/atm.h \ include/grpc/impl/codegen/atm_gcc_atomic.h \ include/grpc/impl/codegen/atm_gcc_sync.h \ include/grpc/impl/codegen/atm_windows.h \ -include/grpc/impl/codegen/log.h \ include/grpc/impl/codegen/port_platform.h \ include/grpc/impl/codegen/slice.h \ include/grpc/impl/codegen/slice_buffer.h \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 295e877062..80c67ce2af 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -5657,7 +5657,6 @@ "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", @@ -5673,7 +5672,6 @@ "include/grpc/impl/codegen/atm_gcc_atomic.h", "include/grpc/impl/codegen/atm_gcc_sync.h", "include/grpc/impl/codegen/atm_windows.h", - "include/grpc/impl/codegen/log.h", "include/grpc/impl/codegen/port_platform.h", "include/grpc/impl/codegen/slice.h", "include/grpc/impl/codegen/slice_buffer.h", diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj b/vsprojects/vcxproj/gpr/gpr.vcxproj index 5df3434bb1..df12d455ff 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj @@ -179,7 +179,6 @@ - diff --git a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters index 4bfef3e3e1..636fd96958 100644 --- a/vsprojects/vcxproj/gpr/gpr.vcxproj.filters +++ b/vsprojects/vcxproj/gpr/gpr.vcxproj.filters @@ -234,9 +234,6 @@ include\grpc\impl\codegen - - include\grpc\impl\codegen - include\grpc\impl\codegen diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj b/vsprojects/vcxproj/grpc++/grpc++.vcxproj index 2538583d70..ac69a3c3b5 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj @@ -345,7 +345,6 @@ - diff --git a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters index e356826fdd..2e50ff5514 100644 --- a/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++/grpc++.vcxproj.filters @@ -363,9 +363,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 af509e7259..b87c3543bb 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj @@ -191,7 +191,6 @@ - diff --git a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters index e40f42915e..5a12bae437 100644 --- a/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_reflection/grpc++_reflection.vcxproj.filters @@ -147,9 +147,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 8146f081b8..ba6b0e41b0 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj @@ -187,7 +187,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 66f264e0cb..75f269c680 100644 --- a/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_test_util/grpc++_test_util.vcxproj.filters @@ -153,9 +153,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 28247a263a..c99e47b942 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj @@ -345,7 +345,6 @@ - diff --git a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters index 2890126200..45bdc496ab 100644 --- a/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc++_unsecure/grpc++_unsecure.vcxproj.filters @@ -348,9 +348,6 @@ include\grpc\impl\codegen - - include\grpc\impl\codegen - include\grpc\impl\codegen diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index cbe040426e..53dd95ec5d 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -283,7 +283,6 @@ - diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index d7ebb21571..4dcf2292cd 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -612,9 +612,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 f5a17653cf..839882066f 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -274,7 +274,6 @@ - diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 5e0056937f..69963d21e7 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -525,9 +525,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 71894e03ed..28f6416a83 100644 --- a/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_full/codegen_test_full.vcxproj @@ -200,7 +200,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 eeff87762c..9ab33e16d2 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 @@ -141,9 +141,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 f6f15c15fa..ffbdf4b160 100644 --- a/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj +++ b/vsprojects/vcxproj/test/codegen_test_minimal/codegen_test_minimal.vcxproj @@ -200,7 +200,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 2297d917a3..342d3aab46 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 @@ -144,9 +144,6 @@ include\grpc\impl\codegen - - include\grpc\impl\codegen - include\grpc\impl\codegen -- cgit v1.2.3 From ff91dea14999225e5f6c9bcf565f28ee3acce6dd Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 11:07:50 -0700 Subject: 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(+) (limited to 'test/cpp/end2end') diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index d587023c65..29007b5e1d 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 b80010e803..a1a964a9d3 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< -- cgit v1.2.3 From 5d94118d0d3e11b0333251fec219e4571f6a20e7 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 4 Aug 2016 11:48:47 -0700 Subject: clang-format --- include/grpc++/impl/codegen/fc_unary.h | 26 ++++++++----- include/grpc++/impl/codegen/method_handler_impl.h | 19 +++++----- include/grpc++/impl/codegen/rpc_method.h | 2 +- include/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(-) (limited to 'test/cpp/end2end') diff --git a/include/grpc++/impl/codegen/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h index 9dbc4024bf..a423f1f0b3 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 14247b1f03..9c3af53b3a 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 728ba3e334..b55d755075 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 02da2a2617..52124fba0b 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 c0eeace8a4..dcfc6b01b7 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 2e63479961..d9b7e6fec5 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 29007b5e1d..252a92d971 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 a1a964a9d3..1512e99a3c 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; -- cgit v1.2.3 From a9c0d7f88b213d9a5e41808fd5d1eceaff1a034f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 29 Aug 2016 16:42:04 -0700 Subject: 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 +- include/grpc++/impl/codegen/completion_queue.h | 8 +- include/grpc++/impl/codegen/fc_unary.h | 90 ---------------------- include/grpc++/impl/codegen/method_handler_impl.h | 81 ++++++++----------- include/grpc++/impl/codegen/server_context.h | 8 +- .../grpc++/impl/codegen/server_streamed_unary.h | 90 ++++++++++++++++++++++ include/grpc++/impl/codegen/service_type.h | 7 +- include/grpc++/impl/codegen/status_code_enum.h | 5 ++ include/grpc++/support/fc_unary.h | 39 ---------- include/grpc++/support/server_streamed_unary.h | 39 ++++++++++ src/compiler/cpp_generator.cc | 44 ++++++----- src/cpp/ext/reflection.grpc.pb.cc | 2 +- test/cpp/end2end/hybrid_end2end_test.cc | 43 ++++++----- 13 files changed, 224 insertions(+), 234 deletions(-) delete mode 100644 include/grpc++/impl/codegen/fc_unary.h create mode 100644 include/grpc++/impl/codegen/server_streamed_unary.h delete mode 100644 include/grpc++/support/fc_unary.h create mode 100644 include/grpc++/support/server_streamed_unary.h (limited to 'test/cpp/end2end') diff --git a/include/grpc++/ext/reflection.grpc.pb.h b/include/grpc++/ext/reflection.grpc.pb.h index 18ec2ea1ec..822c2e374a 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 95ece77ce5..ea317a7a79 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/fc_unary.h b/include/grpc++/impl/codegen/fc_unary.h deleted file mode 100644 index a423f1f0b3..0000000000 --- a/include/grpc++/impl/codegen/fc_unary.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * - * 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 -#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 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. -template -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 { - if (read_done_) { - return false; - } - read_done_ = true; - return ServerReaderWriterInterface::Read( - request); - } - - using WriterInterface::Write; - bool Write(const ResponseType& response, - const WriteOptions& options) GRPC_OVERRIDE { - if (write_done_ || !read_done_) { - return false; - } - write_done_ = true; - return ServerReaderWriterInterface::Write( - response, options); - } - - private: - 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 9c3af53b3a..3a671fe830 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 aadae893ad..8e101c3f15 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/server_streamed_unary.h b/include/grpc++/impl/codegen/server_streamed_unary.h new file mode 100644 index 0000000000..a23e6020ed --- /dev/null +++ b/include/grpc++/impl/codegen/server_streamed_unary.h @@ -0,0 +1,90 @@ +/* + * + * 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_SERVER_STREAMED_UNARY_H +#define GRPCXX_IMPL_CODEGEN_SERVER_STREAMED_UNARY_H + +#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 +/// 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: ServerUnaryStreamer +/// must have exactly 1 Read and exactly 1 Write, in that order, to function +/// correctly. Otherwise, the RPC is in error. +template +class ServerUnaryStreamer GRPC_FINAL + : public ServerReaderWriterInterface { + public: + ServerUnaryStreamer(Call* call, ServerContext* ctx) + : ServerReaderWriterInterface(call, ctx), + read_done_(false), + write_done_(false) {} + + ~ServerUnaryStreamer() {} + + bool Read(RequestType* request) GRPC_OVERRIDE { + if (read_done_) { + return false; + } + read_done_ = true; + return ServerReaderWriterInterface::Read( + request); + } + + using WriterInterface::Write; + bool Write(const ResponseType& response, + const WriteOptions& options) GRPC_OVERRIDE { + if (write_done_ || !read_done_) { + return false; + } + write_done_ = true; + return ServerReaderWriterInterface::Write( + response, options); + } + + private: + bool read_done_; + bool write_done_; +}; +} // namespace grpc + +#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 4af40422a1..9d2a80cbc4 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 9a90a18e2a..0f18a22c36 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/fc_unary.h deleted file mode 100644 index 7e7dea8feb..0000000000 --- a/include/grpc++/support/fc_unary.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * 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/include/grpc++/support/server_streamed_unary.h b/include/grpc++/support/server_streamed_unary.h new file mode 100644 index 0000000000..109dfd4bca --- /dev/null +++ b/include/grpc++/support/server_streamed_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_SERVER_STREAMED_UNARY_H +#define GRPCXX_SUPPORT_SERVER_STREAMED_UNARY_H + +#include + +#endif // GRPCXX_SUPPORT_SERVER_STREAMED_UNARY_H diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index c5d4c2573d..7c70567d12 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 f4a0b97d65..6603eadc4e 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 1512e99a3c..eb7125cb04 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, -- cgit v1.2.3 From d4d5f4cd53a74f7618f720bffa176b05834eb3ac Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Mon, 29 Aug 2016 16:59:21 -0700 Subject: clang-format --- include/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(-) (limited to 'test/cpp/end2end') diff --git a/include/grpc++/impl/codegen/method_handler_impl.h b/include/grpc++/impl/codegen/method_handler_impl.h index 3a671fe830..ef803483ea 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 9d2a80cbc4..72b2225312 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 7c70567d12..744d3d62e8 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 eb7125cb04..a6ea13aa8b 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; -- cgit v1.2.3 From 7c5befd86b56a1eb4d6ed8312d5e722547f39e2d Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Thu, 1 Sep 2016 17:09:47 -0700 Subject: Change UnimplementedService to UnimplementedEchoService in echo.proto --- src/proto/grpc/testing/echo.proto | 2 +- test/cpp/end2end/async_end2end_test.cc | 4 ++-- test/cpp/end2end/end2end_test.cc | 4 ++-- test/cpp/end2end/hybrid_end2end_test.cc | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'test/cpp/end2end') diff --git a/src/proto/grpc/testing/echo.proto b/src/proto/grpc/testing/echo.proto index c596aabfcc..ca60a41b4f 100644 --- a/src/proto/grpc/testing/echo.proto +++ b/src/proto/grpc/testing/echo.proto @@ -42,7 +42,7 @@ service EchoTestService { rpc Unimplemented(EchoRequest) returns (EchoResponse); } -service UnimplementedService { +service UnimplementedEchoService { rpc Unimplemented(EchoRequest) returns (EchoResponse); } diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 4a8936d281..27673c4ea1 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -898,8 +898,8 @@ TEST_P(AsyncEnd2endTest, UnimplementedRpc) { GetChannelCredentials(GetParam().credentials_type, &args); std::shared_ptr channel = CreateCustomChannel(server_address_.str(), channel_creds, args); - std::unique_ptr stub; - stub = grpc::testing::UnimplementedService::NewStub(channel); + std::unique_ptr stub; + stub = grpc::testing::UnimplementedEchoService::NewStub(channel); EchoRequest send_request; EchoResponse recv_response; Status recv_status; diff --git a/test/cpp/end2end/end2end_test.cc b/test/cpp/end2end/end2end_test.cc index 0f87ae3e44..683a71583a 100644 --- a/test/cpp/end2end/end2end_test.cc +++ b/test/cpp/end2end/end2end_test.cc @@ -967,8 +967,8 @@ TEST_P(End2endTest, ChannelStateTimeout) { // Talking to a non-existing service. TEST_P(End2endTest, NonExistingService) { ResetChannel(); - std::unique_ptr stub; - stub = grpc::testing::UnimplementedService::NewStub(channel_); + std::unique_ptr stub; + stub = grpc::testing::UnimplementedEchoService::NewStub(channel_); EchoRequest request; EchoResponse response; diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc index 7e0c0e8a7c..77b0e1f40e 100644 --- a/test/cpp/end2end/hybrid_end2end_test.cc +++ b/test/cpp/end2end/hybrid_end2end_test.cc @@ -346,7 +346,7 @@ class HybridEnd2endTest : public ::testing::Test { EXPECT_TRUE(s.ok()); } - grpc::testing::UnimplementedService::Service unimplemented_service_; + grpc::testing::UnimplementedEchoService::Service unimplemented_service_; std::vector> cqs_; std::unique_ptr stub_; std::unique_ptr server_; -- cgit v1.2.3