diff options
author | Vijay Pai <vpai@google.com> | 2018-11-30 02:16:08 -0800 |
---|---|---|
committer | Vijay Pai <vpai@google.com> | 2018-11-30 04:13:40 -0800 |
commit | ea1156da3fb3d6fb8660d078e70cf5486fc71a65 (patch) | |
tree | a18b3bf4a8d718cf5fe7a2e67c8a951b08bcec5d | |
parent | dac2066a1c0df628fefe4144ae0f97337af6324e (diff) |
Stop exposing streaming object class
-rw-r--r-- | include/grpcpp/generic/generic_stub.h | 6 | ||||
-rw-r--r-- | include/grpcpp/impl/codegen/client_callback.h | 302 | ||||
-rw-r--r-- | src/compiler/cpp_generator.cc | 96 | ||||
-rw-r--r-- | src/cpp/client/generic_stub.cc | 15 | ||||
-rw-r--r-- | test/cpp/codegen/compiler_test_golden | 1105 | ||||
-rw-r--r-- | test/cpp/end2end/client_callback_end2end_test.cc | 63 |
6 files changed, 1053 insertions, 534 deletions
diff --git a/include/grpcpp/generic/generic_stub.h b/include/grpcpp/generic/generic_stub.h index ccbf8a0e55..eb014184e4 100644 --- a/include/grpcpp/generic/generic_stub.h +++ b/include/grpcpp/generic/generic_stub.h @@ -77,9 +77,9 @@ class GenericStub final { const ByteBuffer* request, ByteBuffer* response, std::function<void(Status)> on_completion); - experimental::ClientCallbackReaderWriter<ByteBuffer, ByteBuffer>* - PrepareBidiStreamingCall(ClientContext* context, const grpc::string& method, - experimental::ClientBidiReactor* reactor); + void PrepareBidiStreamingCall( + ClientContext* context, const grpc::string& method, + experimental::ClientBidiReactor<ByteBuffer, ByteBuffer>* reactor); private: GenericStub* stub_; diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 92a588b3c3..999c1c8a3e 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -93,9 +93,67 @@ class CallbackUnaryCallImpl { namespace experimental { +// Forward declarations +template <class Request, class Response> +class ClientBidiReactor; +template <class Response> +class ClientReadReactor; +template <class Request> +class ClientWriteReactor; + +// NOTE: The streaming objects are not actually implemented in the public API. +// These interfaces are provided for mocking only. Typical applications +// will interact exclusively with the reactors that they define. +template <class Request, class Response> +class ClientCallbackReaderWriter { + public: + virtual ~ClientCallbackReaderWriter() {} + virtual void StartCall() = 0; + virtual void Write(const Request* req, WriteOptions options) = 0; + virtual void WritesDone() = 0; + virtual void Read(Response* resp) = 0; + + protected: + void BindReactor(ClientBidiReactor<Request, Response>* reactor) { + reactor->BindStream(this); + } +}; + +template <class Response> +class ClientCallbackReader { + public: + virtual ~ClientCallbackReader() {} + virtual void StartCall() = 0; + virtual void Read(Response* resp) = 0; + + protected: + void BindReactor(ClientReadReactor<Response>* reactor) { + reactor->BindReader(this); + } +}; + +template <class Request> +class ClientCallbackWriter { + public: + virtual ~ClientCallbackWriter() {} + virtual void StartCall() = 0; + void Write(const Request* req) { Write(req, WriteOptions()); } + virtual void Write(const Request* req, WriteOptions options) = 0; + void WriteLast(const Request* req, WriteOptions options) { + Write(req, options.set_last_message()); + } + virtual void WritesDone() = 0; + + protected: + void BindReactor(ClientWriteReactor<Request>* reactor) { + reactor->BindWriter(this); + } +}; + // The user must implement this reactor interface with reactions to each event // type that gets called by the library. An empty reaction is provided by // default +template <class Request, class Response> class ClientBidiReactor { public: virtual ~ClientBidiReactor() {} @@ -104,16 +162,44 @@ class ClientBidiReactor { virtual void OnReadDone(bool ok) {} virtual void OnWriteDone(bool ok) {} virtual void OnWritesDoneDone(bool ok) {} + + void StartCall() { stream_->StartCall(); } + void StartRead(Response* resp) { stream_->Read(resp); } + void StartWrite(const Request* req) { StartWrite(req, WriteOptions()); } + void StartWrite(const Request* req, WriteOptions options) { + stream_->Write(req, std::move(options)); + } + void StartWriteLast(const Request* req, WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); + } + void StartWritesDone() { stream_->WritesDone(); } + + private: + friend class ClientCallbackReaderWriter<Request, Response>; + void BindStream(ClientCallbackReaderWriter<Request, Response>* stream) { + stream_ = stream; + } + ClientCallbackReaderWriter<Request, Response>* stream_; }; +template <class Response> class ClientReadReactor { public: virtual ~ClientReadReactor() {} virtual void OnDone(Status s) {} virtual void OnReadInitialMetadataDone(bool ok) {} virtual void OnReadDone(bool ok) {} + + void StartCall() { reader_->StartCall(); } + void StartRead(Response* resp) { reader_->Read(resp); } + + private: + friend class ClientCallbackReader<Response>; + void BindReader(ClientCallbackReader<Response>* reader) { reader_ = reader; } + ClientCallbackReader<Response>* reader_; }; +template <class Request> class ClientWriteReactor { public: virtual ~ClientWriteReactor() {} @@ -121,41 +207,21 @@ class ClientWriteReactor { virtual void OnReadInitialMetadataDone(bool ok) {} virtual void OnWriteDone(bool ok) {} virtual void OnWritesDoneDone(bool ok) {} -}; -template <class Request, class Response> -class ClientCallbackReaderWriter { - public: - virtual ~ClientCallbackReaderWriter() {} - virtual void StartCall() = 0; - void Write(const Request* req) { Write(req, WriteOptions()); } - virtual void Write(const Request* req, WriteOptions options) = 0; - void WriteLast(const Request* req, WriteOptions options) { - Write(req, options.set_last_message()); + void StartCall() { writer_->StartCall(); } + void StartWrite(const Request* req) { StartWrite(req, WriteOptions()); } + void StartWrite(const Request* req, WriteOptions options) { + writer_->Write(req, std::move(options)); } - virtual void WritesDone() = 0; - virtual void Read(Response* resp) = 0; -}; - -template <class Response> -class ClientCallbackReader { - public: - virtual ~ClientCallbackReader() {} - virtual void StartCall() = 0; - virtual void Read(Response* resp) = 0; -}; - -template <class Request> -class ClientCallbackWriter { - public: - virtual ~ClientCallbackWriter() {} - virtual void StartCall() = 0; - void Write(const Request* req) { Write(req, WriteOptions()); } - virtual void Write(const Request* req, WriteOptions options) = 0; - void WriteLast(const Request* req, WriteOptions options) { - Write(req, options.set_last_message()); + void StartWriteLast(const Request* req, WriteOptions options) { + StartWrite(req, std::move(options.set_last_message())); } - virtual void WritesDone() = 0; + void StartWritesDone() { writer_->WritesDone(); } + + private: + friend class ClientCallbackWriter<Request>; + void BindWriter(ClientCallbackWriter<Request>* writer) { writer_ = writer; } + ClientCallbackWriter<Request>* writer_; }; } // namespace experimental @@ -204,12 +270,13 @@ class ClientCallbackReaderWriterImpl // 4. Any write backlog started_ = true; - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); + start_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); if (!start_corked_) { start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, context_->initial_metadata_flags()); @@ -220,27 +287,29 @@ class ClientCallbackReaderWriterImpl // Also set up the read and write tags so that they don't have to be set up // each time - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeFinish(); - }, - &write_ops_); + write_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_); write_ops_.set_core_cq_tag(&write_tag_); - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeFinish(); - }, - &read_ops_); + read_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_); read_ops_.set_core_cq_tag(&read_tag_); if (read_ops_at_start_) { call_.PerformOps(&read_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); + finish_tag_.Set( + call_.call(), [this](bool ok) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); call_.PerformOps(&finish_ops_); @@ -291,12 +360,13 @@ class ClientCallbackReaderWriterImpl start_corked_ = false; } writes_done_ops_.ClientSendClose(); - writes_done_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWritesDoneDone(ok); - MaybeFinish(); - }, - &writes_done_ops_); + writes_done_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_); writes_done_ops_.set_core_cq_tag(&writes_done_tag_); callbacks_outstanding_++; if (started_) { @@ -311,15 +381,17 @@ class ClientCallbackReaderWriterImpl ClientCallbackReaderWriterImpl( Call call, ClientContext* context, - ::grpc::experimental::ClientBidiReactor* reactor) + ::grpc::experimental::ClientBidiReactor<Request, Response>* reactor) : context_(context), call_(call), reactor_(reactor), - start_corked_(context_->initial_metadata_corked_) {} + start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); + } ClientContext* context_; Call call_; - ::grpc::experimental::ClientBidiReactor* reactor_; + ::grpc::experimental::ClientBidiReactor<Request, Response>* reactor_; CallOpSet<CallOpSendInitialMetadata, CallOpRecvInitialMetadata> start_ops_; CallbackWithSuccessTag start_tag_; @@ -350,14 +422,14 @@ class ClientCallbackReaderWriterImpl template <class Request, class Response> class ClientCallbackReaderWriterFactory { public: - static experimental::ClientCallbackReaderWriter<Request, Response>* Create( + static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, ClientContext* context, - ::grpc::experimental::ClientBidiReactor* reactor) { + ::grpc::experimental::ClientBidiReactor<Request, Response>* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); g_core_codegen_interface->grpc_call_ref(call.call()); - return new (g_core_codegen_interface->grpc_call_arena_alloc( + new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientCallbackReaderWriterImpl<Request, Response>))) ClientCallbackReaderWriterImpl<Request, Response>(call, context, reactor); @@ -396,12 +468,13 @@ class ClientCallbackReaderImpl // 3. Recv trailing metadata, on_completion callback started_ = true; - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); + start_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, context_->initial_metadata_flags()); start_ops_.RecvInitialMetadata(context_); @@ -409,19 +482,20 @@ class ClientCallbackReaderImpl call_.PerformOps(&start_ops_); // Also set up the read tag so it doesn't have to be set up each time - read_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadDone(ok); - MaybeFinish(); - }, - &read_ops_); + read_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnReadDone(ok); + MaybeFinish(); + }, + &read_ops_); read_ops_.set_core_cq_tag(&read_tag_); if (read_ops_at_start_) { call_.PerformOps(&read_ops_); } - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); + finish_tag_.Set( + call_.call(), [this](bool ok) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); call_.PerformOps(&finish_ops_); @@ -441,9 +515,11 @@ class ClientCallbackReaderImpl friend class ClientCallbackReaderFactory<Response>; template <class Request> - ClientCallbackReaderImpl(Call call, ClientContext* context, Request* request, - ::grpc::experimental::ClientReadReactor* reactor) + ClientCallbackReaderImpl( + Call call, ClientContext* context, Request* request, + ::grpc::experimental::ClientReadReactor<Response>* reactor) : context_(context), call_(call), reactor_(reactor) { + this->BindReactor(reactor); // TODO(vjpai): don't assert GPR_CODEGEN_ASSERT(start_ops_.SendMessage(*request).ok()); start_ops_.ClientSendClose(); @@ -451,7 +527,7 @@ class ClientCallbackReaderImpl ClientContext* context_; Call call_; - ::grpc::experimental::ClientReadReactor* reactor_; + ::grpc::experimental::ClientReadReactor<Response>* reactor_; CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage, CallOpClientSendClose, CallOpRecvInitialMetadata> @@ -475,14 +551,14 @@ template <class Response> class ClientCallbackReaderFactory { public: template <class Request> - static experimental::ClientCallbackReader<Response>* Create( + static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, ClientContext* context, const Request* request, - ::grpc::experimental::ClientReadReactor* reactor) { + ::grpc::experimental::ClientReadReactor<Response>* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); g_core_codegen_interface->grpc_call_ref(call.call()); - return new (g_core_codegen_interface->grpc_call_arena_alloc( + new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientCallbackReaderImpl<Response>))) ClientCallbackReaderImpl<Response>(call, context, request, reactor); } @@ -520,12 +596,13 @@ class ClientCallbackWriterImpl // 3. Any backlog started_ = true; - start_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnReadInitialMetadataDone(ok); - MaybeFinish(); - }, - &start_ops_); + start_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnReadInitialMetadataDone(ok); + MaybeFinish(); + }, + &start_ops_); if (!start_corked_) { start_ops_.SendInitialMetadata(&context_->send_initial_metadata_, context_->initial_metadata_flags()); @@ -536,16 +613,17 @@ class ClientCallbackWriterImpl // Also set up the read and write tags so that they don't have to be set up // each time - write_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWriteDone(ok); - MaybeFinish(); - }, - &write_ops_); + write_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnWriteDone(ok); + MaybeFinish(); + }, + &write_ops_); write_ops_.set_core_cq_tag(&write_tag_); - finish_tag_.Set(call_.call(), [this](bool ok) { MaybeFinish(); }, - &finish_ops_); + finish_tag_.Set( + call_.call(), [this](bool ok) { MaybeFinish(); }, &finish_ops_); finish_ops_.ClientRecvStatus(context_, &finish_status_); finish_ops_.set_core_cq_tag(&finish_tag_); call_.PerformOps(&finish_ops_); @@ -586,12 +664,13 @@ class ClientCallbackWriterImpl start_corked_ = false; } writes_done_ops_.ClientSendClose(); - writes_done_tag_.Set(call_.call(), - [this](bool ok) { - reactor_->OnWritesDoneDone(ok); - MaybeFinish(); - }, - &writes_done_ops_); + writes_done_tag_.Set( + call_.call(), + [this](bool ok) { + reactor_->OnWritesDoneDone(ok); + MaybeFinish(); + }, + &writes_done_ops_); writes_done_ops_.set_core_cq_tag(&writes_done_tag_); callbacks_outstanding_++; if (started_) { @@ -605,20 +684,21 @@ class ClientCallbackWriterImpl friend class ClientCallbackWriterFactory<Request>; template <class Response> - ClientCallbackWriterImpl(Call call, ClientContext* context, - Response* response, - ::grpc::experimental::ClientWriteReactor* reactor) + ClientCallbackWriterImpl( + Call call, ClientContext* context, Response* response, + ::grpc::experimental::ClientWriteReactor<Request>* reactor) : context_(context), call_(call), reactor_(reactor), start_corked_(context_->initial_metadata_corked_) { + this->BindReactor(reactor); finish_ops_.RecvMessage(response); finish_ops_.AllowNoMessage(); } ClientContext* context_; Call call_; - ::grpc::experimental::ClientWriteReactor* reactor_; + ::grpc::experimental::ClientWriteReactor<Request>* reactor_; CallOpSet<CallOpSendInitialMetadata, CallOpRecvInitialMetadata> start_ops_; CallbackWithSuccessTag start_tag_; @@ -646,14 +726,14 @@ template <class Request> class ClientCallbackWriterFactory { public: template <class Response> - static experimental::ClientCallbackWriter<Request>* Create( + static void Create( ChannelInterface* channel, const ::grpc::internal::RpcMethod& method, ClientContext* context, Response* response, - ::grpc::experimental::ClientWriteReactor* reactor) { + ::grpc::experimental::ClientWriteReactor<Request>* reactor) { Call call = channel->CreateCall(method, context, channel->CallbackCQ()); g_core_codegen_interface->grpc_call_ref(call.call()); - return new (g_core_codegen_interface->grpc_call_arena_alloc( + new (g_core_codegen_interface->grpc_call_arena_alloc( call.call(), sizeof(ClientCallbackWriterImpl<Request>))) ClientCallbackWriterImpl<Request>(call, context, response, reactor); } diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index 473e57166f..a368b47f01 100644 --- a/src/compiler/cpp_generator.cc +++ b/src/compiler/cpp_generator.cc @@ -582,22 +582,21 @@ void PrintHeaderClientMethodCallbackInterfaces( "std::function<void(::grpc::Status)>) = 0;\n"); } else if (ClientOnlyStreaming(method)) { printer->Print(*vars, - "virtual ::grpc::experimental::ClientCallbackWriter< " - "$Request$>* $Method$(::grpc::ClientContext* context, " + "virtual void $Method$(::grpc::ClientContext* context, " "$Response$* response, " - "::grpc::experimental::ClientWriteReactor* reactor) = 0;\n"); + "::grpc::experimental::ClientWriteReactor< $Request$>* " + "reactor) = 0;\n"); } else if (ServerOnlyStreaming(method)) { printer->Print(*vars, - "virtual ::grpc::experimental::ClientCallbackReader< " - "$Response$>* $Method$(::grpc::ClientContext* context, " + "virtual void $Method$(::grpc::ClientContext* context, " "$Request$* request, " - "::grpc::experimental::ClientReadReactor* reactor) = 0;\n"); + "::grpc::experimental::ClientReadReactor< $Response$>* " + "reactor) = 0;\n"); } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "virtual ::grpc::experimental::ClientCallbackReaderWriter< $Request$, " - "$Response$>* $Method$(::grpc::ClientContext* context, " - "::grpc::experimental::ClientBidiReactor* reactor) = 0;\n"); + printer->Print(*vars, + "virtual void $Method$(::grpc::ClientContext* context, " + "::grpc::experimental::ClientBidiReactor< " + "$Request$,$Response$>* reactor) = 0;\n"); } } @@ -644,26 +643,23 @@ void PrintHeaderClientMethodCallback(grpc_generator::Printer* printer, "const $Request$* request, $Response$* response, " "std::function<void(::grpc::Status)>) override;\n"); } else if (ClientOnlyStreaming(method)) { - printer->Print( - *vars, - "::grpc::experimental::ClientCallbackWriter< $Request$>* " - "$Method$(::grpc::ClientContext* context, " - "$Response$* response, " - "::grpc::experimental::ClientWriteReactor* reactor) override;\n"); + printer->Print(*vars, + "void $Method$(::grpc::ClientContext* context, " + "$Response$* response, " + "::grpc::experimental::ClientWriteReactor< $Request$>* " + "reactor) override;\n"); } else if (ServerOnlyStreaming(method)) { - printer->Print( - *vars, - "::grpc::experimental::ClientCallbackReader< $Response$>* " - "$Method$(::grpc::ClientContext* context, " - "$Request$* request, " - "::grpc::experimental::ClientReadReactor* reactor) override;\n"); + printer->Print(*vars, + "void $Method$(::grpc::ClientContext* context, " + "$Request$* request, " + "::grpc::experimental::ClientReadReactor< $Response$>* " + "reactor) override;\n"); } else if (method->BidiStreaming()) { - printer->Print( - *vars, - "::grpc::experimental::ClientCallbackReaderWriter< $Request$, " - "$Response$>* $Method$(::grpc::ClientContext* context, " - "::grpc::experimental::ClientBidiReactor* reactor) override;\n"); + printer->Print(*vars, + "void $Method$(::grpc::ClientContext* context, " + "::grpc::experimental::ClientBidiReactor< " + "$Request$,$Response$>* reactor) override;\n"); } } @@ -1637,13 +1633,12 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, printer->Print( *vars, - "::grpc::experimental::ClientCallbackWriter< $Request$>* " - "$ns$$Service$::" + "void $ns$$Service$::" "Stub::experimental_async::$Method$(::grpc::ClientContext* context, " "$Response$* response, " - "::grpc::experimental::ClientWriteReactor* reactor) {\n"); + "::grpc::experimental::ClientWriteReactor< $Request$>* reactor) {\n"); printer->Print(*vars, - " return ::grpc::internal::ClientCallbackWriterFactory< " + " ::grpc::internal::ClientCallbackWriterFactory< " "$Request$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -1682,14 +1677,14 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "context, request);\n" "}\n\n"); + printer->Print( + *vars, + "void $ns$$Service$::Stub::experimental_async::$Method$(::grpc::" + "ClientContext* context, " + "$Request$* request, " + "::grpc::experimental::ClientReadReactor< $Response$>* reactor) {\n"); printer->Print(*vars, - "::grpc::experimental::ClientCallbackReader< $Response$>* " - "$ns$$Service$::Stub::experimental_async::$Method$(::grpc::" - "ClientContext* context, " - "$Request$* request, " - "::grpc::experimental::ClientReadReactor* reactor) {\n"); - printer->Print(*vars, - " return ::grpc::internal::ClientCallbackReaderFactory< " + " ::grpc::internal::ClientCallbackReaderFactory< " "$Response$>::Create(" "stub_->channel_.get(), " "stub_->rpcmethod_$Method$_, " @@ -1728,20 +1723,19 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer, "context);\n" "}\n\n"); - printer->Print(*vars, - "::grpc::experimental::ClientCallbackReaderWriter< " - "$Request$,$Response$>* " - "$ns$$Service$::Stub::experimental_async::$Method$(::grpc::" - "ClientContext* context, " - "::grpc::experimental::ClientBidiReactor* reactor) {\n"); printer->Print( *vars, - " return ::grpc::internal::ClientCallbackReaderWriterFactory< " - "$Request$,$Response$>::Create(" - "stub_->channel_.get(), " - "stub_->rpcmethod_$Method$_, " - "context, reactor);\n" - "}\n\n"); + "void $ns$$Service$::Stub::experimental_async::$Method$(::grpc::" + "ClientContext* context, " + "::grpc::experimental::ClientBidiReactor< $Request$,$Response$>* " + "reactor) {\n"); + printer->Print(*vars, + " ::grpc::internal::ClientCallbackReaderWriterFactory< " + "$Request$,$Response$>::Create(" + "stub_->channel_.get(), " + "stub_->rpcmethod_$Method$_, " + "context, reactor);\n" + "}\n\n"); for (auto async_prefix : async_prefixes) { (*vars)["AsyncPrefix"] = async_prefix.prefix; diff --git a/src/cpp/client/generic_stub.cc b/src/cpp/client/generic_stub.cc index f029daec65..f61c1b5317 100644 --- a/src/cpp/client/generic_stub.cc +++ b/src/cpp/client/generic_stub.cc @@ -72,16 +72,13 @@ void GenericStub::experimental_type::UnaryCall( context, request, response, std::move(on_completion)); } -experimental::ClientCallbackReaderWriter<ByteBuffer, ByteBuffer>* -GenericStub::experimental_type::PrepareBidiStreamingCall( +void GenericStub::experimental_type::PrepareBidiStreamingCall( ClientContext* context, const grpc::string& method, - experimental::ClientBidiReactor* reactor) { - return internal::ClientCallbackReaderWriterFactory< - ByteBuffer, ByteBuffer>::Create(stub_->channel_.get(), - internal::RpcMethod( - method.c_str(), - internal::RpcMethod::BIDI_STREAMING), - context, reactor); + experimental::ClientBidiReactor<ByteBuffer, ByteBuffer>* reactor) { + internal::ClientCallbackReaderWriterFactory<ByteBuffer, ByteBuffer>::Create( + stub_->channel_.get(), + internal::RpcMethod(method.c_str(), internal::RpcMethod::BIDI_STREAMING), + context, reactor); } } // namespace grpc diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden index 7a25f51d10..1a5fe27932 100644 --- a/test/cpp/codegen/compiler_test_golden +++ b/test/cpp/codegen/compiler_test_golden @@ -26,7 +26,6 @@ #include "src/proto/grpc/testing/compiler_test.pb.h" -#include <functional> #include <grpcpp/impl/codegen/async_generic_service.h> #include <grpcpp/impl/codegen/async_stream.h> #include <grpcpp/impl/codegen/async_unary_call.h> @@ -39,6 +38,7 @@ #include <grpcpp/impl/codegen/status.h> #include <grpcpp/impl/codegen/stub_options.h> #include <grpcpp/impl/codegen/sync_stream.h> +#include <functional> namespace grpc { class CompletionQueue; @@ -64,294 +64,556 @@ class ServiceA final { public: virtual ~StubInterface() {} // MethodA1 leading comment 1 - virtual ::grpc::Status MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::testing::Response* response) = 0; - std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>> AsyncMethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>>(AsyncMethodA1Raw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>> PrepareAsyncMethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>>(PrepareAsyncMethodA1Raw(context, request, cq)); + virtual ::grpc::Status MethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::testing::Response* response) = 0; + std::unique_ptr< + ::grpc::ClientAsyncResponseReaderInterface<::grpc::testing::Response>> + AsyncMethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>>(AsyncMethodA1Raw(context, request, cq)); + } + std::unique_ptr< + ::grpc::ClientAsyncResponseReaderInterface<::grpc::testing::Response>> + PrepareAsyncMethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>>( + PrepareAsyncMethodA1Raw(context, request, cq)); } // MethodA1 trailing comment 1 // MethodA2 detached leading comment 1 // // Method A2 leading comment 1 // Method A2 leading comment 2 - std::unique_ptr< ::grpc::ClientWriterInterface< ::grpc::testing::Request>> MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response) { - return std::unique_ptr< ::grpc::ClientWriterInterface< ::grpc::testing::Request>>(MethodA2Raw(context, response)); - } - std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpc::testing::Request>> AsyncMethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpc::testing::Request>>(AsyncMethodA2Raw(context, response, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpc::testing::Request>> PrepareAsyncMethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncWriterInterface< ::grpc::testing::Request>>(PrepareAsyncMethodA2Raw(context, response, cq)); + std::unique_ptr<::grpc::ClientWriterInterface<::grpc::testing::Request>> + MethodA2(::grpc::ClientContext* context, + ::grpc::testing::Response* response) { + return std::unique_ptr< + ::grpc::ClientWriterInterface<::grpc::testing::Request>>( + MethodA2Raw(context, response)); + } + std::unique_ptr< + ::grpc::ClientAsyncWriterInterface<::grpc::testing::Request>> + AsyncMethodA2(::grpc::ClientContext* context, + ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq, void* tag) { + return std::unique_ptr< + ::grpc::ClientAsyncWriterInterface<::grpc::testing::Request>>( + AsyncMethodA2Raw(context, response, cq, tag)); + } + std::unique_ptr< + ::grpc::ClientAsyncWriterInterface<::grpc::testing::Request>> + PrepareAsyncMethodA2(::grpc::ClientContext* context, + ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncWriterInterface<::grpc::testing::Request>>( + PrepareAsyncMethodA2Raw(context, response, cq)); } // MethodA2 trailing comment 1 // Method A3 leading comment 1 - std::unique_ptr< ::grpc::ClientReaderInterface< ::grpc::testing::Response>> MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request& request) { - return std::unique_ptr< ::grpc::ClientReaderInterface< ::grpc::testing::Response>>(MethodA3Raw(context, request)); - } - std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::grpc::testing::Response>> AsyncMethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::grpc::testing::Response>>(AsyncMethodA3Raw(context, request, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::grpc::testing::Response>> PrepareAsyncMethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncReaderInterface< ::grpc::testing::Response>>(PrepareAsyncMethodA3Raw(context, request, cq)); + std::unique_ptr<::grpc::ClientReaderInterface<::grpc::testing::Response>> + MethodA3(::grpc::ClientContext* context, + const ::grpc::testing::Request& request) { + return std::unique_ptr< + ::grpc::ClientReaderInterface<::grpc::testing::Response>>( + MethodA3Raw(context, request)); + } + std::unique_ptr< + ::grpc::ClientAsyncReaderInterface<::grpc::testing::Response>> + AsyncMethodA3(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq, void* tag) { + return std::unique_ptr< + ::grpc::ClientAsyncReaderInterface<::grpc::testing::Response>>( + AsyncMethodA3Raw(context, request, cq, tag)); + } + std::unique_ptr< + ::grpc::ClientAsyncReaderInterface<::grpc::testing::Response>> + PrepareAsyncMethodA3(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncReaderInterface<::grpc::testing::Response>>( + PrepareAsyncMethodA3Raw(context, request, cq)); } // Method A3 trailing comment 1 // Method A4 leading comment 1 - std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>> MethodA4(::grpc::ClientContext* context) { - return std::unique_ptr< ::grpc::ClientReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>>(MethodA4Raw(context)); - } - std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>> AsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>>(AsyncMethodA4Raw(context, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>> PrepareAsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq)); + std::unique_ptr<::grpc::ClientReaderWriterInterface< + ::grpc::testing::Request, ::grpc::testing::Response>> + MethodA4(::grpc::ClientContext* context) { + return std::unique_ptr<::grpc::ClientReaderWriterInterface< + ::grpc::testing::Request, ::grpc::testing::Response>>( + MethodA4Raw(context)); + } + std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface< + ::grpc::testing::Request, ::grpc::testing::Response>> + AsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, + void* tag) { + return std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface< + ::grpc::testing::Request, ::grpc::testing::Response>>( + AsyncMethodA4Raw(context, cq, tag)); + } + std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface< + ::grpc::testing::Request, ::grpc::testing::Response>> + PrepareAsyncMethodA4(::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr<::grpc::ClientAsyncReaderWriterInterface< + ::grpc::testing::Request, ::grpc::testing::Response>>( + PrepareAsyncMethodA4Raw(context, cq)); } // Method A4 trailing comment 1 class experimental_async_interface { public: virtual ~experimental_async_interface() {} // MethodA1 leading comment 1 - virtual void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0; + virtual void MethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + std::function<void(::grpc::Status)>) = 0; // MethodA1 trailing comment 1 // MethodA2 detached leading comment 1 // // Method A2 leading comment 1 // Method A2 leading comment 2 - virtual ::grpc::experimental::ClientCallbackWriter< ::grpc::testing::Request>* MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::experimental::ClientWriteReactor* reactor) = 0; + virtual void MethodA2( + ::grpc::ClientContext* context, ::grpc::testing::Response* response, + ::grpc::experimental::ClientWriteReactor<::grpc::testing::Request>* + reactor) = 0; // MethodA2 trailing comment 1 // Method A3 leading comment 1 - virtual ::grpc::experimental::ClientCallbackReader< ::grpc::testing::Response>* MethodA3(::grpc::ClientContext* context, ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor* reactor) = 0; + virtual void MethodA3( + ::grpc::ClientContext* context, ::grpc::testing::Request* request, + ::grpc::experimental::ClientReadReactor<::grpc::testing::Response>* + reactor) = 0; // Method A3 trailing comment 1 // Method A4 leading comment 1 - virtual ::grpc::experimental::ClientCallbackReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4(::grpc::ClientContext* context, ::grpc::experimental::ClientBidiReactor* reactor) = 0; + virtual void MethodA4( + ::grpc::ClientContext* context, + ::grpc::experimental::ClientBidiReactor<::grpc::testing::Request, + ::grpc::testing::Response>* + reactor) = 0; // Method A4 trailing comment 1 }; - virtual class experimental_async_interface* experimental_async() { return nullptr; } - private: - virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; - virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; - virtual ::grpc::ClientWriterInterface< ::grpc::testing::Request>* MethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response) = 0; - virtual ::grpc::ClientAsyncWriterInterface< ::grpc::testing::Request>* AsyncMethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq, void* tag) = 0; - virtual ::grpc::ClientAsyncWriterInterface< ::grpc::testing::Request>* PrepareAsyncMethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq) = 0; - virtual ::grpc::ClientReaderInterface< ::grpc::testing::Response>* MethodA3Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request) = 0; - virtual ::grpc::ClientAsyncReaderInterface< ::grpc::testing::Response>* AsyncMethodA3Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq, void* tag) = 0; - virtual ::grpc::ClientAsyncReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodA3Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; - virtual ::grpc::ClientReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4Raw(::grpc::ClientContext* context) = 0; - virtual ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>* AsyncMethodA4Raw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) = 0; - virtual ::grpc::ClientAsyncReaderWriterInterface< ::grpc::testing::Request, ::grpc::testing::Response>* PrepareAsyncMethodA4Raw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) = 0; + virtual class experimental_async_interface* experimental_async() { + return nullptr; + } + + private: + virtual ::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>* + AsyncMethodA1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>* + PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientWriterInterface<::grpc::testing::Request>* + MethodA2Raw(::grpc::ClientContext* context, + ::grpc::testing::Response* response) = 0; + virtual ::grpc::ClientAsyncWriterInterface<::grpc::testing::Request>* + AsyncMethodA2Raw(::grpc::ClientContext* context, + ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq, void* tag) = 0; + virtual ::grpc::ClientAsyncWriterInterface<::grpc::testing::Request>* + PrepareAsyncMethodA2Raw(::grpc::ClientContext* context, + ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientReaderInterface<::grpc::testing::Response>* + MethodA3Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request) = 0; + virtual ::grpc::ClientAsyncReaderInterface<::grpc::testing::Response>* + AsyncMethodA3Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq, void* tag) = 0; + virtual ::grpc::ClientAsyncReaderInterface<::grpc::testing::Response>* + PrepareAsyncMethodA3Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientReaderWriterInterface<::grpc::testing::Request, + ::grpc::testing::Response>* + MethodA4Raw(::grpc::ClientContext* context) = 0; + virtual ::grpc::ClientAsyncReaderWriterInterface<::grpc::testing::Request, + ::grpc::testing::Response>* + AsyncMethodA4Raw(::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq, void* tag) = 0; + virtual ::grpc::ClientAsyncReaderWriterInterface<::grpc::testing::Request, + ::grpc::testing::Response>* + PrepareAsyncMethodA4Raw(::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq) = 0; }; class Stub final : public StubInterface { public: - Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); - ::grpc::Status MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::testing::Response* response) override; - std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>> AsyncMethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>>(AsyncMethodA1Raw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>> PrepareAsyncMethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>>(PrepareAsyncMethodA1Raw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientWriter< ::grpc::testing::Request>> MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response) { - return std::unique_ptr< ::grpc::ClientWriter< ::grpc::testing::Request>>(MethodA2Raw(context, response)); - } - std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpc::testing::Request>> AsyncMethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpc::testing::Request>>(AsyncMethodA2Raw(context, response, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpc::testing::Request>> PrepareAsyncMethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncWriter< ::grpc::testing::Request>>(PrepareAsyncMethodA2Raw(context, response, cq)); - } - std::unique_ptr< ::grpc::ClientReader< ::grpc::testing::Response>> MethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request& request) { - return std::unique_ptr< ::grpc::ClientReader< ::grpc::testing::Response>>(MethodA3Raw(context, request)); - } - std::unique_ptr< ::grpc::ClientAsyncReader< ::grpc::testing::Response>> AsyncMethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncReader< ::grpc::testing::Response>>(AsyncMethodA3Raw(context, request, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncReader< ::grpc::testing::Response>> PrepareAsyncMethodA3(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncReader< ::grpc::testing::Response>>(PrepareAsyncMethodA3Raw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>> MethodA4(::grpc::ClientContext* context) { - return std::unique_ptr< ::grpc::ClientReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>>(MethodA4Raw(context)); - } - std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>> AsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) { - return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>>(AsyncMethodA4Raw(context, cq, tag)); - } - std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>> PrepareAsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>>(PrepareAsyncMethodA4Raw(context, cq)); - } - class experimental_async final : - public StubInterface::experimental_async_interface { + Stub(const std::shared_ptr<::grpc::ChannelInterface>& channel); + ::grpc::Status MethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::testing::Response* response) override; + std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>> + AsyncMethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>>( + AsyncMethodA1Raw(context, request, cq)); + } + std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>> + PrepareAsyncMethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>>( + PrepareAsyncMethodA1Raw(context, request, cq)); + } + std::unique_ptr<::grpc::ClientWriter<::grpc::testing::Request>> MethodA2( + ::grpc::ClientContext* context, ::grpc::testing::Response* response) { + return std::unique_ptr<::grpc::ClientWriter<::grpc::testing::Request>>( + MethodA2Raw(context, response)); + } + std::unique_ptr<::grpc::ClientAsyncWriter<::grpc::testing::Request>> + AsyncMethodA2(::grpc::ClientContext* context, + ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq, void* tag) { + return std::unique_ptr< + ::grpc::ClientAsyncWriter<::grpc::testing::Request>>( + AsyncMethodA2Raw(context, response, cq, tag)); + } + std::unique_ptr<::grpc::ClientAsyncWriter<::grpc::testing::Request>> + PrepareAsyncMethodA2(::grpc::ClientContext* context, + ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncWriter<::grpc::testing::Request>>( + PrepareAsyncMethodA2Raw(context, response, cq)); + } + std::unique_ptr<::grpc::ClientReader<::grpc::testing::Response>> MethodA3( + ::grpc::ClientContext* context, + const ::grpc::testing::Request& request) { + return std::unique_ptr<::grpc::ClientReader<::grpc::testing::Response>>( + MethodA3Raw(context, request)); + } + std::unique_ptr<::grpc::ClientAsyncReader<::grpc::testing::Response>> + AsyncMethodA3(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq, void* tag) { + return std::unique_ptr< + ::grpc::ClientAsyncReader<::grpc::testing::Response>>( + AsyncMethodA3Raw(context, request, cq, tag)); + } + std::unique_ptr<::grpc::ClientAsyncReader<::grpc::testing::Response>> + PrepareAsyncMethodA3(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncReader<::grpc::testing::Response>>( + PrepareAsyncMethodA3Raw(context, request, cq)); + } + std::unique_ptr<::grpc::ClientReaderWriter<::grpc::testing::Request, + ::grpc::testing::Response>> + MethodA4(::grpc::ClientContext* context) { + return std::unique_ptr<::grpc::ClientReaderWriter< + ::grpc::testing::Request, ::grpc::testing::Response>>( + MethodA4Raw(context)); + } + std::unique_ptr<::grpc::ClientAsyncReaderWriter<::grpc::testing::Request, + ::grpc::testing::Response>> + AsyncMethodA4(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, + void* tag) { + return std::unique_ptr<::grpc::ClientAsyncReaderWriter< + ::grpc::testing::Request, ::grpc::testing::Response>>( + AsyncMethodA4Raw(context, cq, tag)); + } + std::unique_ptr<::grpc::ClientAsyncReaderWriter<::grpc::testing::Request, + ::grpc::testing::Response>> + PrepareAsyncMethodA4(::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr<::grpc::ClientAsyncReaderWriter< + ::grpc::testing::Request, ::grpc::testing::Response>>( + PrepareAsyncMethodA4Raw(context, cq)); + } + class experimental_async final + : public StubInterface::experimental_async_interface { public: - void MethodA1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override; - ::grpc::experimental::ClientCallbackWriter< ::grpc::testing::Request>* MethodA2(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::experimental::ClientWriteReactor* reactor) override; - ::grpc::experimental::ClientCallbackReader< ::grpc::testing::Response>* MethodA3(::grpc::ClientContext* context, ::grpc::testing::Request* request, ::grpc::experimental::ClientReadReactor* reactor) override; - ::grpc::experimental::ClientCallbackReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4(::grpc::ClientContext* context, ::grpc::experimental::ClientBidiReactor* reactor) override; + void MethodA1(::grpc::ClientContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + std::function<void(::grpc::Status)>) override; + void MethodA2( + ::grpc::ClientContext* context, ::grpc::testing::Response* response, + ::grpc::experimental::ClientWriteReactor<::grpc::testing::Request>* + reactor) override; + void MethodA3( + ::grpc::ClientContext* context, ::grpc::testing::Request* request, + ::grpc::experimental::ClientReadReactor<::grpc::testing::Response>* + reactor) override; + void MethodA4(::grpc::ClientContext* context, + ::grpc::experimental::ClientBidiReactor< + ::grpc::testing::Request, ::grpc::testing::Response>* + reactor) override; + private: friend class Stub; - explicit experimental_async(Stub* stub): stub_(stub) { } + explicit experimental_async(Stub* stub) : stub_(stub) {} Stub* stub() { return stub_; } Stub* stub_; }; - class experimental_async_interface* experimental_async() override { return &async_stub_; } - - private: - std::shared_ptr< ::grpc::ChannelInterface> channel_; - class experimental_async async_stub_{this}; - ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; - ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; - ::grpc::ClientWriter< ::grpc::testing::Request>* MethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response) override; - ::grpc::ClientAsyncWriter< ::grpc::testing::Request>* AsyncMethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq, void* tag) override; - ::grpc::ClientAsyncWriter< ::grpc::testing::Request>* PrepareAsyncMethodA2Raw(::grpc::ClientContext* context, ::grpc::testing::Response* response, ::grpc::CompletionQueue* cq) override; - ::grpc::ClientReader< ::grpc::testing::Response>* MethodA3Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request) override; - ::grpc::ClientAsyncReader< ::grpc::testing::Response>* AsyncMethodA3Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq, void* tag) override; - ::grpc::ClientAsyncReader< ::grpc::testing::Response>* PrepareAsyncMethodA3Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; - ::grpc::ClientReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* MethodA4Raw(::grpc::ClientContext* context) override; - ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* AsyncMethodA4Raw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq, void* tag) override; - ::grpc::ClientAsyncReaderWriter< ::grpc::testing::Request, ::grpc::testing::Response>* PrepareAsyncMethodA4Raw(::grpc::ClientContext* context, ::grpc::CompletionQueue* cq) override; + class experimental_async_interface* experimental_async() override { + return &async_stub_; + } + + private: + std::shared_ptr<::grpc::ChannelInterface> channel_; + class experimental_async async_stub_ { + this + }; + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>* + AsyncMethodA1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>* + PrepareAsyncMethodA1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) override; + ::grpc::ClientWriter<::grpc::testing::Request>* MethodA2Raw( + ::grpc::ClientContext* context, + ::grpc::testing::Response* response) override; + ::grpc::ClientAsyncWriter<::grpc::testing::Request>* AsyncMethodA2Raw( + ::grpc::ClientContext* context, ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq, void* tag) override; + ::grpc::ClientAsyncWriter<::grpc::testing::Request>* + PrepareAsyncMethodA2Raw(::grpc::ClientContext* context, + ::grpc::testing::Response* response, + ::grpc::CompletionQueue* cq) override; + ::grpc::ClientReader<::grpc::testing::Response>* MethodA3Raw( + ::grpc::ClientContext* context, + const ::grpc::testing::Request& request) override; + ::grpc::ClientAsyncReader<::grpc::testing::Response>* AsyncMethodA3Raw( + ::grpc::ClientContext* context, const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq, void* tag) override; + ::grpc::ClientAsyncReader<::grpc::testing::Response>* + PrepareAsyncMethodA3Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) override; + ::grpc::ClientReaderWriter<::grpc::testing::Request, + ::grpc::testing::Response>* + MethodA4Raw(::grpc::ClientContext* context) override; + ::grpc::ClientAsyncReaderWriter<::grpc::testing::Request, + ::grpc::testing::Response>* + AsyncMethodA4Raw(::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq, void* tag) override; + ::grpc::ClientAsyncReaderWriter<::grpc::testing::Request, + ::grpc::testing::Response>* + PrepareAsyncMethodA4Raw(::grpc::ClientContext* context, + ::grpc::CompletionQueue* cq) override; const ::grpc::internal::RpcMethod rpcmethod_MethodA1_; const ::grpc::internal::RpcMethod rpcmethod_MethodA2_; const ::grpc::internal::RpcMethod rpcmethod_MethodA3_; const ::grpc::internal::RpcMethod rpcmethod_MethodA4_; }; - static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions()); + static std::unique_ptr<Stub> NewStub( + const std::shared_ptr<::grpc::ChannelInterface>& channel, + const ::grpc::StubOptions& options = ::grpc::StubOptions()); class Service : public ::grpc::Service { public: Service(); virtual ~Service(); // MethodA1 leading comment 1 - virtual ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response); + virtual ::grpc::Status MethodA1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response); // MethodA1 trailing comment 1 // MethodA2 detached leading comment 1 // // Method A2 leading comment 1 // Method A2 leading comment 2 - virtual ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response); + virtual ::grpc::Status MethodA2( + ::grpc::ServerContext* context, + ::grpc::ServerReader<::grpc::testing::Request>* reader, + ::grpc::testing::Response* response); // MethodA2 trailing comment 1 // Method A3 leading comment 1 - virtual ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer); + virtual ::grpc::Status MethodA3( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::ServerWriter<::grpc::testing::Response>* writer); // Method A3 trailing comment 1 // Method A4 leading comment 1 - virtual ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream); + virtual ::grpc::Status MethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerReaderWriter<::grpc::testing::Response, + ::grpc::testing::Request>* stream); // Method A4 trailing comment 1 }; template <class BaseClass> class WithAsyncMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithAsyncMethod_MethodA1() { - ::grpc::Service::MarkMethodAsync(0); - } + WithAsyncMethod_MethodA1() { ::grpc::Service::MarkMethodAsync(0); } ~WithAsyncMethod_MethodA1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA1(::grpc::ServerContext* context, ::grpc::testing::Request* request, ::grpc::ServerAsyncResponseWriter< ::grpc::testing::Response>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag); + void RequestMethodA1( + ::grpc::ServerContext* context, ::grpc::testing::Request* request, + ::grpc::ServerAsyncResponseWriter<::grpc::testing::Response>* response, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncUnary(0, context, request, response, + new_call_cq, notification_cq, tag); } }; template <class BaseClass> class WithAsyncMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithAsyncMethod_MethodA2() { - ::grpc::Service::MarkMethodAsync(1); - } + WithAsyncMethod_MethodA2() { ::grpc::Service::MarkMethodAsync(1); } ~WithAsyncMethod_MethodA2() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2( + ::grpc::ServerContext* context, + ::grpc::ServerReader<::grpc::testing::Request>* reader, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA2(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::grpc::testing::Response, ::grpc::testing::Request>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncClientStreaming(1, context, reader, new_call_cq, notification_cq, tag); + void RequestMethodA2( + ::grpc::ServerContext* context, + ::grpc::ServerAsyncReader<::grpc::testing::Response, + ::grpc::testing::Request>* reader, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncClientStreaming( + 1, context, reader, new_call_cq, notification_cq, tag); } }; template <class BaseClass> class WithAsyncMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithAsyncMethod_MethodA3() { - ::grpc::Service::MarkMethodAsync(2); - } + WithAsyncMethod_MethodA3() { ::grpc::Service::MarkMethodAsync(2); } ~WithAsyncMethod_MethodA3() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::ServerWriter<::grpc::testing::Response>* writer) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA3(::grpc::ServerContext* context, ::grpc::testing::Request* request, ::grpc::ServerAsyncWriter< ::grpc::testing::Response>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncServerStreaming(2, context, request, writer, new_call_cq, notification_cq, tag); + void RequestMethodA3( + ::grpc::ServerContext* context, ::grpc::testing::Request* request, + ::grpc::ServerAsyncWriter<::grpc::testing::Response>* writer, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncServerStreaming( + 2, context, request, writer, new_call_cq, notification_cq, tag); } }; template <class BaseClass> class WithAsyncMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithAsyncMethod_MethodA4() { - ::grpc::Service::MarkMethodAsync(3); - } + WithAsyncMethod_MethodA4() { ::grpc::Service::MarkMethodAsync(3); } ~WithAsyncMethod_MethodA4() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerReaderWriter<::grpc::testing::Response, + ::grpc::testing::Request>* stream) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA4(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag); + void RequestMethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerAsyncReaderWriter<::grpc::testing::Response, + ::grpc::testing::Request>* stream, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncBidiStreaming( + 3, context, stream, new_call_cq, notification_cq, tag); } }; - typedef WithAsyncMethod_MethodA1<WithAsyncMethod_MethodA2<WithAsyncMethod_MethodA3<WithAsyncMethod_MethodA4<Service > > > > AsyncService; + typedef WithAsyncMethod_MethodA1<WithAsyncMethod_MethodA2< + WithAsyncMethod_MethodA3<WithAsyncMethod_MethodA4<Service>>>> + AsyncService; template <class BaseClass> class ExperimentalWithCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: ExperimentalWithCallbackMethod_MethodA1() { - ::grpc::Service::experimental().MarkMethodCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ExperimentalWithCallbackMethod_MethodA1<BaseClass>, ::grpc::testing::Request, ::grpc::testing::Response>( - [this](::grpc::ServerContext* context, - const ::grpc::testing::Request* request, - ::grpc::testing::Response* response, - ::grpc::experimental::ServerCallbackRpcController* controller) { + ::grpc::Service::experimental().MarkMethodCallback( + 0, new ::grpc::internal::CallbackUnaryHandler< + ExperimentalWithCallbackMethod_MethodA1<BaseClass>, + ::grpc::testing::Request, ::grpc::testing::Response>( + [this](::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + ::grpc::experimental::ServerCallbackRpcController* + controller) { this->MethodA1(context, request, response, controller); - }, this)); + }, + this)); } ~ExperimentalWithCallbackMethod_MethodA1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodA1( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + ::grpc::experimental::ServerCallbackRpcController* controller) { + controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } }; template <class BaseClass> class ExperimentalWithCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - ExperimentalWithCallbackMethod_MethodA2() { - } + ExperimentalWithCallbackMethod_MethodA2() {} ~ExperimentalWithCallbackMethod_MethodA2() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2( + ::grpc::ServerContext* context, + ::grpc::ServerReader<::grpc::testing::Request>* reader, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -359,15 +621,17 @@ class ServiceA final { template <class BaseClass> class ExperimentalWithCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - ExperimentalWithCallbackMethod_MethodA3() { - } + ExperimentalWithCallbackMethod_MethodA3() {} ~ExperimentalWithCallbackMethod_MethodA3() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::ServerWriter<::grpc::testing::Response>* writer) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -375,33 +639,41 @@ class ServiceA final { template <class BaseClass> class ExperimentalWithCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - ExperimentalWithCallbackMethod_MethodA4() { - } + ExperimentalWithCallbackMethod_MethodA4() {} ~ExperimentalWithCallbackMethod_MethodA4() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerReaderWriter<::grpc::testing::Response, + ::grpc::testing::Request>* stream) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } }; - typedef ExperimentalWithCallbackMethod_MethodA1<ExperimentalWithCallbackMethod_MethodA2<ExperimentalWithCallbackMethod_MethodA3<ExperimentalWithCallbackMethod_MethodA4<Service > > > > ExperimentalCallbackService; + typedef ExperimentalWithCallbackMethod_MethodA1< + ExperimentalWithCallbackMethod_MethodA2< + ExperimentalWithCallbackMethod_MethodA3< + ExperimentalWithCallbackMethod_MethodA4<Service>>>> + ExperimentalCallbackService; template <class BaseClass> class WithGenericMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithGenericMethod_MethodA1() { - ::grpc::Service::MarkMethodGeneric(0); - } + WithGenericMethod_MethodA1() { ::grpc::Service::MarkMethodGeneric(0); } ~WithGenericMethod_MethodA1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -409,16 +681,18 @@ class ServiceA final { template <class BaseClass> class WithGenericMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithGenericMethod_MethodA2() { - ::grpc::Service::MarkMethodGeneric(1); - } + WithGenericMethod_MethodA2() { ::grpc::Service::MarkMethodGeneric(1); } ~WithGenericMethod_MethodA2() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2( + ::grpc::ServerContext* context, + ::grpc::ServerReader<::grpc::testing::Request>* reader, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -426,16 +700,17 @@ class ServiceA final { template <class BaseClass> class WithGenericMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithGenericMethod_MethodA3() { - ::grpc::Service::MarkMethodGeneric(2); - } + WithGenericMethod_MethodA3() { ::grpc::Service::MarkMethodGeneric(2); } ~WithGenericMethod_MethodA3() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::ServerWriter<::grpc::testing::Response>* writer) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -443,16 +718,18 @@ class ServiceA final { template <class BaseClass> class WithGenericMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithGenericMethod_MethodA4() { - ::grpc::Service::MarkMethodGeneric(3); - } + WithGenericMethod_MethodA4() { ::grpc::Service::MarkMethodGeneric(3); } ~WithGenericMethod_MethodA4() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerReaderWriter<::grpc::testing::Response, + ::grpc::testing::Request>* stream) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -460,120 +737,164 @@ class ServiceA final { template <class BaseClass> class WithRawMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithRawMethod_MethodA1() { - ::grpc::Service::MarkMethodRaw(0); - } + WithRawMethod_MethodA1() { ::grpc::Service::MarkMethodRaw(0); } ~WithRawMethod_MethodA1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA1(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag); + void RequestMethodA1( + ::grpc::ServerContext* context, ::grpc::ByteBuffer* request, + ::grpc::ServerAsyncResponseWriter<::grpc::ByteBuffer>* response, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncUnary(0, context, request, response, + new_call_cq, notification_cq, tag); } }; template <class BaseClass> class WithRawMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithRawMethod_MethodA2() { - ::grpc::Service::MarkMethodRaw(1); - } + WithRawMethod_MethodA2() { ::grpc::Service::MarkMethodRaw(1); } ~WithRawMethod_MethodA2() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2( + ::grpc::ServerContext* context, + ::grpc::ServerReader<::grpc::testing::Request>* reader, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA2(::grpc::ServerContext* context, ::grpc::ServerAsyncReader< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* reader, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncClientStreaming(1, context, reader, new_call_cq, notification_cq, tag); + void RequestMethodA2(::grpc::ServerContext* context, + ::grpc::ServerAsyncReader<::grpc::ByteBuffer, + ::grpc::ByteBuffer>* reader, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, + void* tag) { + ::grpc::Service::RequestAsyncClientStreaming( + 1, context, reader, new_call_cq, notification_cq, tag); } }; template <class BaseClass> class WithRawMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithRawMethod_MethodA3() { - ::grpc::Service::MarkMethodRaw(2); - } + WithRawMethod_MethodA3() { ::grpc::Service::MarkMethodRaw(2); } ~WithRawMethod_MethodA3() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::ServerWriter<::grpc::testing::Response>* writer) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA3(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncWriter< ::grpc::ByteBuffer>* writer, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncServerStreaming(2, context, request, writer, new_call_cq, notification_cq, tag); + void RequestMethodA3(::grpc::ServerContext* context, + ::grpc::ByteBuffer* request, + ::grpc::ServerAsyncWriter<::grpc::ByteBuffer>* writer, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, + void* tag) { + ::grpc::Service::RequestAsyncServerStreaming( + 2, context, request, writer, new_call_cq, notification_cq, tag); } }; template <class BaseClass> class WithRawMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithRawMethod_MethodA4() { - ::grpc::Service::MarkMethodRaw(3); - } + WithRawMethod_MethodA4() { ::grpc::Service::MarkMethodRaw(3); } ~WithRawMethod_MethodA4() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerReaderWriter<::grpc::testing::Response, + ::grpc::testing::Request>* stream) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodA4(::grpc::ServerContext* context, ::grpc::ServerAsyncReaderWriter< ::grpc::ByteBuffer, ::grpc::ByteBuffer>* stream, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncBidiStreaming(3, context, stream, new_call_cq, notification_cq, tag); + void RequestMethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerAsyncReaderWriter<::grpc::ByteBuffer, ::grpc::ByteBuffer>* + stream, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncBidiStreaming( + 3, context, stream, new_call_cq, notification_cq, tag); } }; template <class BaseClass> class ExperimentalWithRawCallbackMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: ExperimentalWithRawCallbackMethod_MethodA1() { - ::grpc::Service::experimental().MarkMethodRawCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ExperimentalWithRawCallbackMethod_MethodA1<BaseClass>, ::grpc::ByteBuffer, ::grpc::ByteBuffer>( - [this](::grpc::ServerContext* context, - const ::grpc::ByteBuffer* request, - ::grpc::ByteBuffer* response, - ::grpc::experimental::ServerCallbackRpcController* controller) { + ::grpc::Service::experimental().MarkMethodRawCallback( + 0, new ::grpc::internal::CallbackUnaryHandler< + ExperimentalWithRawCallbackMethod_MethodA1<BaseClass>, + ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + [this](::grpc::ServerContext* context, + const ::grpc::ByteBuffer* request, + ::grpc::ByteBuffer* response, + ::grpc::experimental::ServerCallbackRpcController* + controller) { this->MethodA1(context, request, response, controller); - }, this)); + }, + this)); } ~ExperimentalWithRawCallbackMethod_MethodA1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodA1(::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodA1( + ::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, + ::grpc::ByteBuffer* response, + ::grpc::experimental::ServerCallbackRpcController* controller) { + controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } }; template <class BaseClass> class ExperimentalWithRawCallbackMethod_MethodA2 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - ExperimentalWithRawCallbackMethod_MethodA2() { - } + ExperimentalWithRawCallbackMethod_MethodA2() {} ~ExperimentalWithRawCallbackMethod_MethodA2() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA2(::grpc::ServerContext* context, ::grpc::ServerReader< ::grpc::testing::Request>* reader, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA2( + ::grpc::ServerContext* context, + ::grpc::ServerReader<::grpc::testing::Request>* reader, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -581,15 +902,17 @@ class ServiceA final { template <class BaseClass> class ExperimentalWithRawCallbackMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - ExperimentalWithRawCallbackMethod_MethodA3() { - } + ExperimentalWithRawCallbackMethod_MethodA3() {} ~ExperimentalWithRawCallbackMethod_MethodA3() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::ServerWriter<::grpc::testing::Response>* writer) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -597,15 +920,18 @@ class ServiceA final { template <class BaseClass> class ExperimentalWithRawCallbackMethod_MethodA4 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - ExperimentalWithRawCallbackMethod_MethodA4() { - } + ExperimentalWithRawCallbackMethod_MethodA4() {} ~ExperimentalWithRawCallbackMethod_MethodA4() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodA4(::grpc::ServerContext* context, ::grpc::ServerReaderWriter< ::grpc::testing::Response, ::grpc::testing::Request>* stream) override { + ::grpc::Status MethodA4( + ::grpc::ServerContext* context, + ::grpc::ServerReaderWriter<::grpc::testing::Response, + ::grpc::testing::Request>* stream) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -613,46 +939,69 @@ class ServiceA final { template <class BaseClass> class WithStreamedUnaryMethod_MethodA1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: WithStreamedUnaryMethod_MethodA1() { - ::grpc::Service::MarkMethodStreamed(0, - new ::grpc::internal::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodA1<BaseClass>::StreamedMethodA1, this, std::placeholders::_1, std::placeholders::_2))); + ::grpc::Service::MarkMethodStreamed( + 0, new ::grpc::internal::StreamedUnaryHandler< + ::grpc::testing::Request, ::grpc::testing::Response>(std::bind( + &WithStreamedUnaryMethod_MethodA1<BaseClass>::StreamedMethodA1, + this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_MethodA1() override { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodA1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodA1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } // replace default version of method with streamed unary - virtual ::grpc::Status StreamedMethodA1(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpc::testing::Request,::grpc::testing::Response>* server_unary_streamer) = 0; + virtual ::grpc::Status StreamedMethodA1( + ::grpc::ServerContext* context, + ::grpc::ServerUnaryStreamer<::grpc::testing::Request, + ::grpc::testing::Response>* + server_unary_streamer) = 0; }; - typedef WithStreamedUnaryMethod_MethodA1<Service > StreamedUnaryService; + typedef WithStreamedUnaryMethod_MethodA1<Service> StreamedUnaryService; template <class BaseClass> class WithSplitStreamingMethod_MethodA3 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: WithSplitStreamingMethod_MethodA3() { - ::grpc::Service::MarkMethodStreamed(2, - new ::grpc::internal::SplitServerStreamingHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithSplitStreamingMethod_MethodA3<BaseClass>::StreamedMethodA3, this, std::placeholders::_1, std::placeholders::_2))); + ::grpc::Service::MarkMethodStreamed( + 2, + new ::grpc::internal::SplitServerStreamingHandler< + ::grpc::testing::Request, ::grpc::testing::Response>(std::bind( + &WithSplitStreamingMethod_MethodA3<BaseClass>::StreamedMethodA3, + this, std::placeholders::_1, std::placeholders::_2))); } ~WithSplitStreamingMethod_MethodA3() override { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodA3(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::ServerWriter< ::grpc::testing::Response>* writer) override { + ::grpc::Status MethodA3( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::ServerWriter<::grpc::testing::Response>* writer) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } // replace default version of method with split streamed - virtual ::grpc::Status StreamedMethodA3(::grpc::ServerContext* context, ::grpc::ServerSplitStreamer< ::grpc::testing::Request,::grpc::testing::Response>* server_split_streamer) = 0; + virtual ::grpc::Status StreamedMethodA3( + ::grpc::ServerContext* context, + ::grpc::ServerSplitStreamer<::grpc::testing::Request, + ::grpc::testing::Response>* + server_split_streamer) = 0; }; - typedef WithSplitStreamingMethod_MethodA3<Service > SplitStreamedService; - typedef WithStreamedUnaryMethod_MethodA1<WithSplitStreamingMethod_MethodA3<Service > > StreamedService; + typedef WithSplitStreamingMethod_MethodA3<Service> SplitStreamedService; + typedef WithStreamedUnaryMethod_MethodA1< + WithSplitStreamingMethod_MethodA3<Service>> + StreamedService; }; // ServiceB leading comment 1 @@ -665,125 +1014,204 @@ class ServiceB final { public: virtual ~StubInterface() {} // MethodB1 leading comment 1 - virtual ::grpc::Status MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::testing::Response* response) = 0; - std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>> AsyncMethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>>(AsyncMethodB1Raw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>> PrepareAsyncMethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq)); + virtual ::grpc::Status MethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::testing::Response* response) = 0; + std::unique_ptr< + ::grpc::ClientAsyncResponseReaderInterface<::grpc::testing::Response>> + AsyncMethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>>(AsyncMethodB1Raw(context, request, cq)); + } + std::unique_ptr< + ::grpc::ClientAsyncResponseReaderInterface<::grpc::testing::Response>> + PrepareAsyncMethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr<::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>>( + PrepareAsyncMethodB1Raw(context, request, cq)); } // MethodB1 trailing comment 1 class experimental_async_interface { public: virtual ~experimental_async_interface() {} // MethodB1 leading comment 1 - virtual void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) = 0; + virtual void MethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + std::function<void(::grpc::Status)>) = 0; // MethodB1 trailing comment 1 }; - virtual class experimental_async_interface* experimental_async() { return nullptr; } - private: - virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; - virtual ::grpc::ClientAsyncResponseReaderInterface< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) = 0; + virtual class experimental_async_interface* experimental_async() { + return nullptr; + } + + private: + virtual ::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>* + AsyncMethodB1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) = 0; + virtual ::grpc::ClientAsyncResponseReaderInterface< + ::grpc::testing::Response>* + PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) = 0; }; class Stub final : public StubInterface { public: - Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel); - ::grpc::Status MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::testing::Response* response) override; - std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>> AsyncMethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>>(AsyncMethodB1Raw(context, request, cq)); - } - std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>> PrepareAsyncMethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) { - return std::unique_ptr< ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>>(PrepareAsyncMethodB1Raw(context, request, cq)); - } - class experimental_async final : - public StubInterface::experimental_async_interface { + Stub(const std::shared_ptr<::grpc::ChannelInterface>& channel); + ::grpc::Status MethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::testing::Response* response) override; + std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>> + AsyncMethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>>( + AsyncMethodB1Raw(context, request, cq)); + } + std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>> + PrepareAsyncMethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) { + return std::unique_ptr< + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>>( + PrepareAsyncMethodB1Raw(context, request, cq)); + } + class experimental_async final + : public StubInterface::experimental_async_interface { public: - void MethodB1(::grpc::ClientContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, std::function<void(::grpc::Status)>) override; + void MethodB1(::grpc::ClientContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + std::function<void(::grpc::Status)>) override; + private: friend class Stub; - explicit experimental_async(Stub* stub): stub_(stub) { } + explicit experimental_async(Stub* stub) : stub_(stub) {} Stub* stub() { return stub_; } Stub* stub_; }; - class experimental_async_interface* experimental_async() override { return &async_stub_; } + class experimental_async_interface* experimental_async() override { + return &async_stub_; + } private: - std::shared_ptr< ::grpc::ChannelInterface> channel_; - class experimental_async async_stub_{this}; - ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* AsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; - ::grpc::ClientAsyncResponseReader< ::grpc::testing::Response>* PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, const ::grpc::testing::Request& request, ::grpc::CompletionQueue* cq) override; + std::shared_ptr<::grpc::ChannelInterface> channel_; + class experimental_async async_stub_ { + this + }; + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>* + AsyncMethodB1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) override; + ::grpc::ClientAsyncResponseReader<::grpc::testing::Response>* + PrepareAsyncMethodB1Raw(::grpc::ClientContext* context, + const ::grpc::testing::Request& request, + ::grpc::CompletionQueue* cq) override; const ::grpc::internal::RpcMethod rpcmethod_MethodB1_; }; - static std::unique_ptr<Stub> NewStub(const std::shared_ptr< ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions()); + static std::unique_ptr<Stub> NewStub( + const std::shared_ptr<::grpc::ChannelInterface>& channel, + const ::grpc::StubOptions& options = ::grpc::StubOptions()); class Service : public ::grpc::Service { public: Service(); virtual ~Service(); // MethodB1 leading comment 1 - virtual ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response); + virtual ::grpc::Status MethodB1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response); // MethodB1 trailing comment 1 }; template <class BaseClass> class WithAsyncMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithAsyncMethod_MethodB1() { - ::grpc::Service::MarkMethodAsync(0); - } + WithAsyncMethod_MethodB1() { ::grpc::Service::MarkMethodAsync(0); } ~WithAsyncMethod_MethodB1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodB1(::grpc::ServerContext* context, ::grpc::testing::Request* request, ::grpc::ServerAsyncResponseWriter< ::grpc::testing::Response>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag); + void RequestMethodB1( + ::grpc::ServerContext* context, ::grpc::testing::Request* request, + ::grpc::ServerAsyncResponseWriter<::grpc::testing::Response>* response, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncUnary(0, context, request, response, + new_call_cq, notification_cq, tag); } }; - typedef WithAsyncMethod_MethodB1<Service > AsyncService; + typedef WithAsyncMethod_MethodB1<Service> AsyncService; template <class BaseClass> class ExperimentalWithCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: ExperimentalWithCallbackMethod_MethodB1() { - ::grpc::Service::experimental().MarkMethodCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ExperimentalWithCallbackMethod_MethodB1<BaseClass>, ::grpc::testing::Request, ::grpc::testing::Response>( - [this](::grpc::ServerContext* context, - const ::grpc::testing::Request* request, - ::grpc::testing::Response* response, - ::grpc::experimental::ServerCallbackRpcController* controller) { + ::grpc::Service::experimental().MarkMethodCallback( + 0, new ::grpc::internal::CallbackUnaryHandler< + ExperimentalWithCallbackMethod_MethodB1<BaseClass>, + ::grpc::testing::Request, ::grpc::testing::Response>( + [this](::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + ::grpc::experimental::ServerCallbackRpcController* + controller) { this->MethodB1(context, request, response, controller); - }, this)); + }, + this)); } ~ExperimentalWithCallbackMethod_MethodB1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodB1( + ::grpc::ServerContext* context, const ::grpc::testing::Request* request, + ::grpc::testing::Response* response, + ::grpc::experimental::ServerCallbackRpcController* controller) { + controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } }; - typedef ExperimentalWithCallbackMethod_MethodB1<Service > ExperimentalCallbackService; + typedef ExperimentalWithCallbackMethod_MethodB1<Service> + ExperimentalCallbackService; template <class BaseClass> class WithGenericMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithGenericMethod_MethodB1() { - ::grpc::Service::MarkMethodGeneric(0); - } + WithGenericMethod_MethodB1() { ::grpc::Service::MarkMethodGeneric(0); } ~WithGenericMethod_MethodB1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } @@ -791,76 +1219,103 @@ class ServiceB final { template <class BaseClass> class WithRawMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: - WithRawMethod_MethodB1() { - ::grpc::Service::MarkMethodRaw(0); - } + WithRawMethod_MethodB1() { ::grpc::Service::MarkMethodRaw(0); } ~WithRawMethod_MethodB1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - void RequestMethodB1(::grpc::ServerContext* context, ::grpc::ByteBuffer* request, ::grpc::ServerAsyncResponseWriter< ::grpc::ByteBuffer>* response, ::grpc::CompletionQueue* new_call_cq, ::grpc::ServerCompletionQueue* notification_cq, void *tag) { - ::grpc::Service::RequestAsyncUnary(0, context, request, response, new_call_cq, notification_cq, tag); + void RequestMethodB1( + ::grpc::ServerContext* context, ::grpc::ByteBuffer* request, + ::grpc::ServerAsyncResponseWriter<::grpc::ByteBuffer>* response, + ::grpc::CompletionQueue* new_call_cq, + ::grpc::ServerCompletionQueue* notification_cq, void* tag) { + ::grpc::Service::RequestAsyncUnary(0, context, request, response, + new_call_cq, notification_cq, tag); } }; template <class BaseClass> class ExperimentalWithRawCallbackMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: ExperimentalWithRawCallbackMethod_MethodB1() { - ::grpc::Service::experimental().MarkMethodRawCallback(0, - new ::grpc::internal::CallbackUnaryHandler< ExperimentalWithRawCallbackMethod_MethodB1<BaseClass>, ::grpc::ByteBuffer, ::grpc::ByteBuffer>( - [this](::grpc::ServerContext* context, - const ::grpc::ByteBuffer* request, - ::grpc::ByteBuffer* response, - ::grpc::experimental::ServerCallbackRpcController* controller) { + ::grpc::Service::experimental().MarkMethodRawCallback( + 0, new ::grpc::internal::CallbackUnaryHandler< + ExperimentalWithRawCallbackMethod_MethodB1<BaseClass>, + ::grpc::ByteBuffer, ::grpc::ByteBuffer>( + [this](::grpc::ServerContext* context, + const ::grpc::ByteBuffer* request, + ::grpc::ByteBuffer* response, + ::grpc::experimental::ServerCallbackRpcController* + controller) { this->MethodB1(context, request, response, controller); - }, this)); + }, + this)); } ~ExperimentalWithRawCallbackMethod_MethodB1() override { BaseClassMustBeDerivedFromService(this); } // disable synchronous version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } - virtual void MethodB1(::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, ::grpc::ByteBuffer* response, ::grpc::experimental::ServerCallbackRpcController* controller) { controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); } + virtual void MethodB1( + ::grpc::ServerContext* context, const ::grpc::ByteBuffer* request, + ::grpc::ByteBuffer* response, + ::grpc::experimental::ServerCallbackRpcController* controller) { + controller->Finish(::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, "")); + } }; template <class BaseClass> class WithStreamedUnaryMethod_MethodB1 : public BaseClass { private: - void BaseClassMustBeDerivedFromService(const Service *service) {} + void BaseClassMustBeDerivedFromService(const Service* service) {} + public: WithStreamedUnaryMethod_MethodB1() { - ::grpc::Service::MarkMethodStreamed(0, - new ::grpc::internal::StreamedUnaryHandler< ::grpc::testing::Request, ::grpc::testing::Response>(std::bind(&WithStreamedUnaryMethod_MethodB1<BaseClass>::StreamedMethodB1, this, std::placeholders::_1, std::placeholders::_2))); + ::grpc::Service::MarkMethodStreamed( + 0, new ::grpc::internal::StreamedUnaryHandler< + ::grpc::testing::Request, ::grpc::testing::Response>(std::bind( + &WithStreamedUnaryMethod_MethodB1<BaseClass>::StreamedMethodB1, + this, std::placeholders::_1, std::placeholders::_2))); } ~WithStreamedUnaryMethod_MethodB1() override { BaseClassMustBeDerivedFromService(this); } // disable regular version of this method - ::grpc::Status MethodB1(::grpc::ServerContext* context, const ::grpc::testing::Request* request, ::grpc::testing::Response* response) override { + ::grpc::Status MethodB1(::grpc::ServerContext* context, + const ::grpc::testing::Request* request, + ::grpc::testing::Response* response) override { abort(); return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED, ""); } // replace default version of method with streamed unary - virtual ::grpc::Status StreamedMethodB1(::grpc::ServerContext* context, ::grpc::ServerUnaryStreamer< ::grpc::testing::Request,::grpc::testing::Response>* server_unary_streamer) = 0; + virtual ::grpc::Status StreamedMethodB1( + ::grpc::ServerContext* context, + ::grpc::ServerUnaryStreamer<::grpc::testing::Request, + ::grpc::testing::Response>* + server_unary_streamer) = 0; }; - typedef WithStreamedUnaryMethod_MethodB1<Service > StreamedUnaryService; + typedef WithStreamedUnaryMethod_MethodB1<Service> StreamedUnaryService; typedef Service SplitStreamedService; - typedef WithStreamedUnaryMethod_MethodB1<Service > StreamedService; + typedef WithStreamedUnaryMethod_MethodB1<Service> StreamedService; }; // ServiceB trailing comment 1 } // namespace testing } // namespace grpc - #endif // GRPC_src_2fproto_2fgrpc_2ftesting_2fcompiler_5ftest_2eproto__INCLUDED diff --git a/test/cpp/end2end/client_callback_end2end_test.cc b/test/cpp/end2end/client_callback_end2end_test.cc index 57c3cb87f2..a1fe199b54 100644 --- a/test/cpp/end2end/client_callback_end2end_test.cc +++ b/test/cpp/end2end/client_callback_end2end_test.cc @@ -187,20 +187,20 @@ class ClientCallbackEnd2endTest grpc::string test_string(""); for (int i = 0; i < num_rpcs; i++) { test_string += "Hello world. "; - class Client : public grpc::experimental::ClientBidiReactor { + class Client : public grpc::experimental::ClientBidiReactor<ByteBuffer, + ByteBuffer> { public: Client(ClientCallbackEnd2endTest* test, const grpc::string& method_name, const grpc::string& test_str) { - stream_ = - test->generic_stub_->experimental().PrepareBidiStreamingCall( - &cli_ctx_, method_name, this); + test->generic_stub_->experimental().PrepareBidiStreamingCall( + &cli_ctx_, method_name, this); request_.set_message(test_str); send_buf_ = SerializeToByteBuffer(&request_); - stream_->Write(send_buf_.get()); - stream_->Read(&recv_buf_); - stream_->StartCall(); + StartWrite(send_buf_.get()); + StartRead(&recv_buf_); + StartCall(); } - void OnWriteDone(bool ok) override { stream_->WritesDone(); } + void OnWriteDone(bool ok) override { StartWritesDone(); } void OnReadDone(bool ok) override { EchoResponse response; EXPECT_TRUE(ParseFromByteBuffer(&recv_buf_, &response)); @@ -223,8 +223,6 @@ class ClientCallbackEnd2endTest std::unique_ptr<ByteBuffer> send_buf_; ByteBuffer recv_buf_; ClientContext cli_ctx_; - experimental::ClientCallbackReaderWriter<ByteBuffer, ByteBuffer>* - stream_; std::mutex mu_; std::condition_variable cv_; bool done_ = false; @@ -330,22 +328,21 @@ TEST_P(ClientCallbackEnd2endTest, RequestStream) { } ResetStub(); - class Client : public grpc::experimental::ClientWriteReactor { + class Client : public grpc::experimental::ClientWriteReactor<EchoRequest> { public: explicit Client(grpc::testing::EchoTestService::Stub* stub) { context_.set_initial_metadata_corked(true); - stream_ = stub->experimental_async()->RequestStream(&context_, &response_, - this); - stream_->StartCall(); + stub->experimental_async()->RequestStream(&context_, &response_, this); + StartCall(); request_.set_message("Hello server."); - stream_->Write(&request_); + StartWrite(&request_); } void OnWriteDone(bool ok) override { writes_left_--; if (writes_left_ > 1) { - stream_->Write(&request_); + StartWrite(&request_); } else if (writes_left_ == 1) { - stream_->WriteLast(&request_, WriteOptions()); + StartWriteLast(&request_, WriteOptions()); } } void OnDone(Status s) override { @@ -363,7 +360,6 @@ TEST_P(ClientCallbackEnd2endTest, RequestStream) { } private: - ::grpc::experimental::ClientCallbackWriter<EchoRequest>* stream_; EchoRequest request_; EchoResponse response_; ClientContext context_; @@ -383,14 +379,13 @@ TEST_P(ClientCallbackEnd2endTest, ResponseStream) { } ResetStub(); - class Client : public grpc::experimental::ClientReadReactor { + class Client : public grpc::experimental::ClientReadReactor<EchoResponse> { public: explicit Client(grpc::testing::EchoTestService::Stub* stub) { request_.set_message("Hello client "); - stream_ = stub->experimental_async()->ResponseStream(&context_, &request_, - this); - stream_->StartCall(); - stream_->Read(&response_); + stub->experimental_async()->ResponseStream(&context_, &request_, this); + StartCall(); + StartRead(&response_); } void OnReadDone(bool ok) override { if (!ok) { @@ -400,7 +395,7 @@ TEST_P(ClientCallbackEnd2endTest, ResponseStream) { EXPECT_EQ(response_.message(), request_.message() + grpc::to_string(reads_complete_)); reads_complete_++; - stream_->Read(&response_); + StartRead(&response_); } } void OnDone(Status s) override { @@ -417,7 +412,6 @@ TEST_P(ClientCallbackEnd2endTest, ResponseStream) { } private: - ::grpc::experimental::ClientCallbackReader<EchoResponse>* stream_; EchoRequest request_; EchoResponse response_; ClientContext context_; @@ -436,14 +430,15 @@ TEST_P(ClientCallbackEnd2endTest, BidiStream) { return; } ResetStub(); - class Client : public grpc::experimental::ClientBidiReactor { + class Client : public grpc::experimental::ClientBidiReactor<EchoRequest, + EchoResponse> { public: explicit Client(grpc::testing::EchoTestService::Stub* stub) { request_.set_message("Hello fren "); - stream_ = stub->experimental_async()->BidiStream(&context_, this); - stream_->StartCall(); - stream_->Read(&response_); - stream_->Write(&request_); + stub->experimental_async()->BidiStream(&context_, this); + StartCall(); + StartRead(&response_); + StartWrite(&request_); } void OnReadDone(bool ok) override { if (!ok) { @@ -452,15 +447,15 @@ TEST_P(ClientCallbackEnd2endTest, BidiStream) { EXPECT_LE(reads_complete_, kServerDefaultResponseStreamsToSend); EXPECT_EQ(response_.message(), request_.message()); reads_complete_++; - stream_->Read(&response_); + StartRead(&response_); } } void OnWriteDone(bool ok) override { EXPECT_TRUE(ok); if (++writes_complete_ == kServerDefaultResponseStreamsToSend) { - stream_->WritesDone(); + StartWritesDone(); } else { - stream_->Write(&request_); + StartWrite(&request_); } } void OnDone(Status s) override { @@ -477,8 +472,6 @@ TEST_P(ClientCallbackEnd2endTest, BidiStream) { } private: - ::grpc::experimental::ClientCallbackReaderWriter<EchoRequest, EchoResponse>* - stream_; EchoRequest request_; EchoResponse response_; ClientContext context_; |