diff --git a/BUILD b/BUILD index c7760c6228f..5dcf3b282f6 100644 --- a/BUILD +++ b/BUILD @@ -134,7 +134,6 @@ GRPCXX_SRCS = [ "src/cpp/client/create_channel_internal.cc", "src/cpp/client/create_channel_posix.cc", "src/cpp/client/credentials_cc.cc", - "src/cpp/client/generic_stub.cc", "src/cpp/common/alarm.cc", "src/cpp/common/channel_arguments.cc", "src/cpp/common/channel_filter.cc", diff --git a/BUILD.gn b/BUILD.gn index 827f3fcecfa..d0a9b061737 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1396,7 +1396,6 @@ config("grpc_config") { "src/cpp/client/create_channel_internal.h", "src/cpp/client/create_channel_posix.cc", "src/cpp/client/credentials_cc.cc", - "src/cpp/client/generic_stub.cc", "src/cpp/client/insecure_credentials.cc", "src/cpp/client/secure_credentials.cc", "src/cpp/client/secure_credentials.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 9852948a8a6..dca74707d22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3677,7 +3677,6 @@ add_library(grpc++ src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc src/cpp/client/credentials_cc.cc - src/cpp/client/generic_stub.cc src/cpp/common/alarm.cc src/cpp/common/channel_arguments.cc src/cpp/common/channel_filter.cc @@ -4811,7 +4810,6 @@ add_library(grpc++_unsecure src/cpp/client/create_channel_internal.cc src/cpp/client/create_channel_posix.cc src/cpp/client/credentials_cc.cc - src/cpp/client/generic_stub.cc src/cpp/common/alarm.cc src/cpp/common/channel_arguments.cc src/cpp/common/channel_filter.cc diff --git a/Makefile b/Makefile index a746da2cb03..2c93b1a0847 100644 --- a/Makefile +++ b/Makefile @@ -6062,7 +6062,6 @@ LIBGRPC++_SRC = \ src/cpp/client/create_channel_internal.cc \ src/cpp/client/create_channel_posix.cc \ src/cpp/client/credentials_cc.cc \ - src/cpp/client/generic_stub.cc \ src/cpp/common/alarm.cc \ src/cpp/common/channel_arguments.cc \ src/cpp/common/channel_filter.cc \ @@ -7170,7 +7169,6 @@ LIBGRPC++_UNSECURE_SRC = \ src/cpp/client/create_channel_internal.cc \ src/cpp/client/create_channel_posix.cc \ src/cpp/client/credentials_cc.cc \ - src/cpp/client/generic_stub.cc \ src/cpp/common/alarm.cc \ src/cpp/common/channel_arguments.cc \ src/cpp/common/channel_filter.cc \ diff --git a/build.yaml b/build.yaml index 79ab6309c11..eb66e51804c 100644 --- a/build.yaml +++ b/build.yaml @@ -595,7 +595,6 @@ filegroups: - src/cpp/client/create_channel_internal.cc - src/cpp/client/create_channel_posix.cc - src/cpp/client/credentials_cc.cc - - src/cpp/client/generic_stub.cc - src/cpp/common/alarm.cc - src/cpp/common/channel_arguments.cc - src/cpp/common/channel_filter.cc diff --git a/gRPC-C++.podspec b/gRPC-C++.podspec index c70c1ab5b78..44a59f601cb 100644 --- a/gRPC-C++.podspec +++ b/gRPC-C++.podspec @@ -591,7 +591,6 @@ Pod::Spec.new do |s| 'src/cpp/client/create_channel_internal.h', 'src/cpp/client/create_channel_posix.cc', 'src/cpp/client/credentials_cc.cc', - 'src/cpp/client/generic_stub.cc', 'src/cpp/client/insecure_credentials.cc', 'src/cpp/client/secure_credentials.cc', 'src/cpp/client/secure_credentials.h', diff --git a/grpc.gyp b/grpc.gyp index 46503f7422c..7067a8f7c7b 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -1805,7 +1805,6 @@ 'src/cpp/client/create_channel_internal.cc', 'src/cpp/client/create_channel_posix.cc', 'src/cpp/client/credentials_cc.cc', - 'src/cpp/client/generic_stub.cc', 'src/cpp/common/alarm.cc', 'src/cpp/common/channel_arguments.cc', 'src/cpp/common/channel_filter.cc', @@ -1977,7 +1976,6 @@ 'src/cpp/client/create_channel_internal.cc', 'src/cpp/client/create_channel_posix.cc', 'src/cpp/client/credentials_cc.cc', - 'src/cpp/client/generic_stub.cc', 'src/cpp/common/alarm.cc', 'src/cpp/common/channel_arguments.cc', 'src/cpp/common/channel_filter.cc', diff --git a/include/grpcpp/generic/generic_stub_impl.h b/include/grpcpp/generic/generic_stub_impl.h index 4aca1cd5393..e272e73c8ec 100644 --- a/include/grpcpp/generic/generic_stub_impl.h +++ b/include/grpcpp/generic/generic_stub_impl.h @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -50,16 +51,24 @@ class GenericStub final { /// The return value only indicates whether or not registration of the call /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr PrepareCall( - grpc::ClientContext* context, const grpc::string& method, - CompletionQueue* cq); + ClientContext* context, const grpc::string& method, CompletionQueue* cq) { + return CallInternal(channel_.get(), context, method, cq, false, nullptr); + } /// Setup a unary call to a named method \a method using \a context, and don't /// start it. Let it be started explicitly with StartCall. /// The return value only indicates whether or not registration of the call /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr PrepareUnaryCall( - grpc_impl::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer& request, CompletionQueue* cq); + ClientContext* context, const grpc::string& method, + const grpc::ByteBuffer& request, CompletionQueue* cq) { + return std::unique_ptr( + internal::ClientAsyncResponseReaderFactory::Create( + channel_.get(), cq, + grpc::internal::RpcMethod(method.c_str(), + grpc::internal::RpcMethod::NORMAL_RPC), + context, request, false)); + } /// DEPRECATED for multi-threaded use /// Begin a call to a named method \a method using \a context. @@ -68,13 +77,15 @@ class GenericStub final { /// The return value only indicates whether or not registration of the call /// succeeded (i.e. the call won't proceed if the return value is nullptr). std::unique_ptr Call( - grpc_impl::ClientContext* context, const grpc::string& method, - CompletionQueue* cq, void* tag); + ClientContext* context, const grpc::string& method, CompletionQueue* cq, + void* tag) { + return CallInternal(channel_.get(), context, method, cq, true, tag); + } #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL /// Setup and start a unary call to a named method \a method using /// \a context and specifying the \a request and \a response buffers. - void UnaryCall(grpc_impl::ClientContext* context, const grpc::string& method, + void UnaryCall(ClientContext* context, const grpc::string& method, const grpc::ByteBuffer* request, grpc::ByteBuffer* response, std::function on_completion) { UnaryCallInternal(context, method, request, response, @@ -85,11 +96,10 @@ class GenericStub final { /// \a context and specifying the \a request and \a response buffers. /// Like any other reactor-based RPC, it will not be activated until /// StartCall is invoked on its reactor. - void PrepareUnaryCall(grpc_impl::ClientContext* context, - const grpc::string& method, + void PrepareUnaryCall(ClientContext* context, const grpc::string& method, const grpc::ByteBuffer* request, grpc::ByteBuffer* response, - grpc_impl::ClientUnaryReactor* reactor) { + ClientUnaryReactor* reactor) { PrepareUnaryCallInternal(context, method, request, response, reactor); } @@ -97,9 +107,8 @@ class GenericStub final { /// \a reactor . Like any other bidi streaming RPC, it will not be activated /// until StartCall is invoked on its reactor. void PrepareBidiStreamingCall( - grpc_impl::ClientContext* context, const grpc::string& method, - grpc_impl::ClientBidiReactor* - reactor) { + ClientContext* context, const grpc::string& method, + ClientBidiReactor* reactor) { PrepareBidiStreamingCallInternal(context, method, reactor); } #endif @@ -113,9 +122,8 @@ class GenericStub final { /// Setup and start a unary call to a named method \a method using /// \a context and specifying the \a request and \a response buffers. - void UnaryCall(grpc_impl::ClientContext* context, - const grpc::string& method, const grpc::ByteBuffer* request, - grpc::ByteBuffer* response, + void UnaryCall(ClientContext* context, const grpc::string& method, + const grpc::ByteBuffer* request, grpc::ByteBuffer* response, std::function on_completion) { stub_->UnaryCallInternal(context, method, request, response, std::move(on_completion)); @@ -125,11 +133,10 @@ class GenericStub final { /// \a context and specifying the \a request and \a response buffers. /// Like any other reactor-based RPC, it will not be activated until /// StartCall is invoked on its reactor. - void PrepareUnaryCall(grpc_impl::ClientContext* context, - const grpc::string& method, + void PrepareUnaryCall(ClientContext* context, const grpc::string& method, const grpc::ByteBuffer* request, grpc::ByteBuffer* response, - grpc_impl::ClientUnaryReactor* reactor) { + ClientUnaryReactor* reactor) { stub_->PrepareUnaryCallInternal(context, method, request, response, reactor); } @@ -138,9 +145,8 @@ class GenericStub final { /// \a reactor . Like any other bidi streaming RPC, it will not be activated /// until StartCall is invoked on its reactor. void PrepareBidiStreamingCall( - grpc_impl::ClientContext* context, const grpc::string& method, - grpc_impl::ClientBidiReactor* - reactor) { + ClientContext* context, const grpc::string& method, + ClientBidiReactor* reactor) { stub_->PrepareBidiStreamingCallInternal(context, method, reactor); } @@ -156,22 +162,53 @@ class GenericStub final { private: std::shared_ptr channel_; - void UnaryCallInternal(grpc_impl::ClientContext* context, - const grpc::string& method, + void UnaryCallInternal(ClientContext* context, const grpc::string& method, const grpc::ByteBuffer* request, grpc::ByteBuffer* response, - std::function on_completion); + std::function on_completion) { + internal::CallbackUnaryCall( + channel_.get(), + grpc::internal::RpcMethod(method.c_str(), + grpc::internal::RpcMethod::NORMAL_RPC), + context, request, response, std::move(on_completion)); + } - void PrepareUnaryCallInternal(grpc_impl::ClientContext* context, + void PrepareUnaryCallInternal(ClientContext* context, const grpc::string& method, const grpc::ByteBuffer* request, grpc::ByteBuffer* response, - grpc_impl::ClientUnaryReactor* reactor); + ClientUnaryReactor* reactor) { + internal::ClientCallbackUnaryFactory::Create( + channel_.get(), + grpc::internal::RpcMethod(method.c_str(), + grpc::internal::RpcMethod::NORMAL_RPC), + context, request, response, reactor); + } void PrepareBidiStreamingCallInternal( - grpc_impl::ClientContext* context, const grpc::string& method, - grpc_impl::ClientBidiReactor* - reactor); + ClientContext* context, const grpc::string& method, + ClientBidiReactor* reactor) { + internal::ClientCallbackReaderWriterFactory:: + Create(channel_.get(), + grpc::internal::RpcMethod( + method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING), + context, reactor); + } + + std::unique_ptr CallInternal( + grpc::ChannelInterface* channel, ClientContext* context, + const grpc::string& method, CompletionQueue* cq, bool start, void* tag) { + return std::unique_ptr( + internal::ClientAsyncReaderWriterFactory:: + Create( + channel, cq, + grpc::internal::RpcMethod( + method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING), + context, start, tag)); + } }; } // namespace grpc_impl diff --git a/src/cpp/client/generic_stub.cc b/src/cpp/client/generic_stub.cc deleted file mode 100644 index aa28226f506..00000000000 --- a/src/cpp/client/generic_stub.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* - * - * Copyright 2015 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include - -namespace grpc_impl { - -namespace { -std::unique_ptr CallInternal( - grpc::ChannelInterface* channel, grpc::ClientContext* context, - const grpc::string& method, CompletionQueue* cq, bool start, void* tag) { - return std::unique_ptr( - internal::ClientAsyncReaderWriterFactory:: - Create(channel, cq, - grpc::internal::RpcMethod( - method.c_str(), grpc::internal::RpcMethod::BIDI_STREAMING), - context, start, tag)); -} - -} // namespace - -// begin a call to a named method -std::unique_ptr GenericStub::Call( - grpc::ClientContext* context, const grpc::string& method, - CompletionQueue* cq, void* tag) { - return CallInternal(channel_.get(), context, method, cq, true, tag); -} - -// setup a call to a named method -std::unique_ptr GenericStub::PrepareCall( - grpc::ClientContext* context, const grpc::string& method, - CompletionQueue* cq) { - return CallInternal(channel_.get(), context, method, cq, false, nullptr); -} - -// setup a unary call to a named method -std::unique_ptr -GenericStub::PrepareUnaryCall(grpc::ClientContext* context, - const grpc::string& method, - const grpc::ByteBuffer& request, - CompletionQueue* cq) { - return std::unique_ptr( - internal::ClientAsyncResponseReaderFactory::Create( - channel_.get(), cq, - grpc::internal::RpcMethod(method.c_str(), - grpc::internal::RpcMethod::NORMAL_RPC), - context, request, false)); -} - -void GenericStub::UnaryCallInternal( - grpc::ClientContext* context, const grpc::string& method, - const grpc::ByteBuffer* request, grpc::ByteBuffer* response, - std::function on_completion) { - internal::CallbackUnaryCall( - channel_.get(), - grpc::internal::RpcMethod(method.c_str(), - grpc::internal::RpcMethod::NORMAL_RPC), - context, request, response, std::move(on_completion)); -} - -void GenericStub::PrepareBidiStreamingCallInternal( - grpc::ClientContext* context, const grpc::string& method, - ClientBidiReactor* reactor) { - internal::ClientCallbackReaderWriterFactory< - grpc::ByteBuffer, - grpc::ByteBuffer>::Create(channel_.get(), - grpc::internal::RpcMethod( - method.c_str(), - grpc::internal::RpcMethod::BIDI_STREAMING), - context, reactor); -} - -void GenericStub::PrepareUnaryCallInternal(grpc::ClientContext* context, - const grpc::string& method, - const grpc::ByteBuffer* request, - grpc::ByteBuffer* response, - ClientUnaryReactor* reactor) { - internal::ClientCallbackUnaryFactory::Create( - channel_.get(), - grpc::internal::RpcMethod(method.c_str(), - grpc::internal::RpcMethod::NORMAL_RPC), - context, request, response, reactor); -} - -} // namespace grpc_impl diff --git a/tools/doxygen/Doxyfile.c++.internal b/tools/doxygen/Doxyfile.c++.internal index 6891c5cc35a..4408ada7f66 100644 --- a/tools/doxygen/Doxyfile.c++.internal +++ b/tools/doxygen/Doxyfile.c++.internal @@ -1247,7 +1247,6 @@ src/cpp/client/create_channel_internal.cc \ src/cpp/client/create_channel_internal.h \ src/cpp/client/create_channel_posix.cc \ src/cpp/client/credentials_cc.cc \ -src/cpp/client/generic_stub.cc \ src/cpp/client/insecure_credentials.cc \ src/cpp/client/secure_credentials.cc \ src/cpp/client/secure_credentials.h \