From 62e01dd922121075c5af750ce8395a372bd9593f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 3 Dec 2019 21:36:23 -0800 Subject: [PATCH] Add non-experimental:: versions under ifdef --- include/grpcpp/impl/codegen/client_callback.h | 26 +++++++++++++++++++ .../grpcpp/impl/codegen/message_allocator.h | 20 ++++++++++++++ include/grpcpp/impl/codegen/server_callback.h | 16 ++++++++++++ include/grpcpp/impl/codegen/server_context.h | 6 +++++ src/cpp/server/server_cc.cc | 17 ++++++------ 5 files changed, 77 insertions(+), 8 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_callback.h b/include/grpcpp/impl/codegen/client_callback.h index 7893a6ff3ba..a8b58f6b700 100644 --- a/include/grpcpp/impl/codegen/client_callback.h +++ b/include/grpcpp/impl/codegen/client_callback.h @@ -22,6 +22,31 @@ #include namespace grpc { + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +template +using ClientCallbackReader = ::grpc_impl::ClientCallbackReader; + +template +using ClientCallbackWriter = ::grpc_impl::ClientCallbackWriter; + +template +using ClientCallbackReaderWriter = + ::grpc_impl::ClientCallbackReaderWriter; + +template +using ClientReadReactor = ::grpc_impl::ClientReadReactor; + +template +using ClientWriteReactor = ::grpc_impl::ClientWriteReactor; + +template +using ClientBidiReactor = ::grpc_impl::ClientBidiReactor; + +typedef ::grpc_impl::ClientUnaryReactor ClientUnaryReactor; +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. namespace experimental { template @@ -44,6 +69,7 @@ template using ClientBidiReactor = ::grpc_impl::ClientBidiReactor; typedef ::grpc_impl::ClientUnaryReactor ClientUnaryReactor; + } // namespace experimental } // namespace grpc diff --git a/include/grpcpp/impl/codegen/message_allocator.h b/include/grpcpp/impl/codegen/message_allocator.h index 83544c64068..4048ea11974 100644 --- a/include/grpcpp/impl/codegen/message_allocator.h +++ b/include/grpcpp/impl/codegen/message_allocator.h @@ -20,7 +20,9 @@ #define GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H namespace grpc { +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL namespace experimental { +#endif // NOTE: This is an API for advanced users who need custom allocators. // Per rpc struct for the allocator. This is the interface to return to user. @@ -67,7 +69,25 @@ class MessageAllocator { virtual MessageHolder* AllocateMessages() = 0; }; +#ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL } // namespace experimental +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +namespace experimental { + +using ::grpc::RpcAllocatorState; + +template +using MessageHolder = ::grpc::MessageHolder; + +template +using MessageAllocator = ::grpc::MessageAllocator; + +} // namespace experimental +#endif + } // namespace grpc #endif // GRPCPP_IMPL_CODEGEN_MESSAGE_ALLOCATOR_H diff --git a/include/grpcpp/impl/codegen/server_callback.h b/include/grpcpp/impl/codegen/server_callback.h index 3ddd8f6f81d..1d8b2f6f5bb 100644 --- a/include/grpcpp/impl/codegen/server_callback.h +++ b/include/grpcpp/impl/codegen/server_callback.h @@ -22,7 +22,23 @@ #include namespace grpc { + +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +template +using ServerReadReactor = ::grpc_impl::ServerReadReactor; + +template +using ServerWriteReactor = ::grpc_impl::ServerWriteReactor; + +template +using ServerBidiReactor = ::grpc_impl::ServerBidiReactor; + +using ServerUnaryReactor = ::grpc_impl::ServerUnaryReactor; +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. namespace experimental { + template using ServerReadReactor = ::grpc_impl::ServerReadReactor; diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index b04a4cea19e..85b309e6d52 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -25,6 +25,12 @@ namespace grpc { typedef ::grpc_impl::ServerContext ServerContext; +#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL +typedef ::grpc_impl::ServerContextBase ServerContextBase; +typedef ::grpc_impl::CallbackServerContext CallbackServerContext; +#endif + +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. namespace experimental { typedef ::grpc_impl::ServerContextBase ServerContextBase; diff --git a/src/cpp/server/server_cc.cc b/src/cpp/server/server_cc.cc index 54b42dccd86..0bc1da0480f 100644 --- a/src/cpp/server/server_cc.cc +++ b/src/cpp/server/server_cc.cc @@ -111,6 +111,7 @@ class UnimplementedAsyncRequestContext { // de-experimentalized fully. #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL using ::grpc::experimental::CallbackGenericService; +using ::grpc::experimental::CallbackServerContext; using ::grpc::experimental::GenericCallbackServerContext; #endif @@ -551,9 +552,9 @@ class Server::CallbackRequestBase : public grpc::internal::CompletionQueueTag { template class Server::CallbackRequest final : public Server::CallbackRequestBase { public: - static_assert(std::is_base_of::value, - "ServerContextType must be derived from CallbackServerContext"); + static_assert( + std::is_base_of::value, + "ServerContextType must be derived from CallbackServerContext"); // The constructor needs to know the server for this callback request and its // index in the server's request count array to allow for proper dynamic @@ -807,8 +808,8 @@ class Server::CallbackRequest final : public Server::CallbackRequestBase { }; template <> -bool Server::CallbackRequest:: - FinalizeResult(void** /*tag*/, bool* /*status*/) { +bool Server::CallbackRequest::FinalizeResult( + void** /*tag*/, bool* /*status*/) { return false; } @@ -827,8 +828,8 @@ bool Server::CallbackRequest< } template <> -const char* Server::CallbackRequest< - grpc::experimental::CallbackServerContext>::method_name() const { +const char* Server::CallbackRequest::method_name() + const { return method_->name(); } @@ -1140,7 +1141,7 @@ bool Server::RegisterService(const grpc::string* host, grpc::Service* service) { // TODO(vjpai): Register these dynamically based on need for (int i = 0; i < DEFAULT_CALLBACK_REQS_PER_METHOD; i++) { callback_reqs_to_start_.push_back( - new CallbackRequest( + new CallbackRequest( this, method_index, method.get(), method_registration_tag)); } // Enqueue it so that it will be Request'ed later after all request