From a23578444cfb2d41f225917abdd9ffed24bd06af Mon Sep 17 00:00:00 2001 From: Karthik Ravi Shankar Date: Thu, 20 Aug 2020 14:16:23 -0700 Subject: [PATCH] Fix and format build after rebase --- include/grpcpp/impl/codegen/client_context.h | 13 +++--- .../grpcpp/impl/codegen/method_handler_impl.h | 42 ++++++++----------- .../grpcpp/impl/codegen/rpc_service_method.h | 4 +- .../impl/codegen/server_callback_handlers.h | 29 +++++-------- include/grpcpp/impl/codegen/server_context.h | 18 +++++--- .../grpcpp/impl/codegen/server_interface.h | 6 +-- .../grpcpp/impl/codegen/sync_stream_impl.h | 12 ++---- src/cpp/client/client_context.cc | 3 +- 8 files changed, 58 insertions(+), 69 deletions(-) diff --git a/include/grpcpp/impl/codegen/client_context.h b/include/grpcpp/impl/codegen/client_context.h index dfcae0d3657..ce338720f2c 100644 --- a/include/grpcpp/impl/codegen/client_context.h +++ b/include/grpcpp/impl/codegen/client_context.h @@ -71,7 +71,6 @@ class ClientCallbackUnaryImpl; class ClientContextAccessor; } // namespace internal -class ServerContext; template class ClientReader; template @@ -87,12 +86,14 @@ class ClientAsyncReaderWriter; template class ClientAsyncResponseReader; -class ServerContextBase; -class CallbackServerContext; } // namespace grpc_impl namespace grpc { +class ServerContext; +class ServerContextBase; +class CallbackServerContext; + namespace testing { class InteropClientContextInspector; } // namespace testing @@ -208,10 +209,10 @@ class ClientContext { /// \return A newly constructed \a ClientContext instance based on \a /// server_context, with traits propagated (copied) according to \a options. static std::unique_ptr FromServerContext( - const grpc_impl::ServerContext& server_context, + const grpc::ServerContext& server_context, PropagationOptions options = PropagationOptions()); static std::unique_ptr FromCallbackServerContext( - const grpc_impl::CallbackServerContext& server_context, + const grpc::CallbackServerContext& server_context, PropagationOptions options = PropagationOptions()); /// Add the (\a meta_key, \a meta_value) pair to the metadata associated with @@ -491,7 +492,7 @@ class ClientContext { void SendCancelToInterceptors(); static std::unique_ptr FromInternalServerContext( - const grpc_impl::ServerContextBase& server_context, + const grpc::ServerContextBase& server_context, PropagationOptions options); bool initial_metadata_received_; diff --git a/include/grpcpp/impl/codegen/method_handler_impl.h b/include/grpcpp/impl/codegen/method_handler_impl.h index f7d1f9c4ecf..19f2eb22e13 100644 --- a/include/grpcpp/impl/codegen/method_handler_impl.h +++ b/include/grpcpp/impl/codegen/method_handler_impl.h @@ -65,10 +65,9 @@ class RpcMethodHandler : public ::grpc::internal::MethodHandler { ::grpc::Status status = param.status; if (status.ok()) { status = CatchingFunctionHandler([this, ¶m, &rsp] { - return func_( - service_, - static_cast<::grpc::ServerContext*>(param.server_context), - static_cast(param.request), &rsp); + return func_(service_, + static_cast<::grpc::ServerContext*>(param.server_context), + static_cast(param.request), &rsp); }); static_cast(param.request)->~RequestType(); } @@ -131,16 +130,14 @@ class ClientStreamingHandler : public ::grpc::internal::MethodHandler { void RunHandler(const HandlerParameter& param) final { ::grpc_impl::ServerReader reader( - param.call, - static_cast<::grpc::ServerContext*>(param.server_context)); + param.call, static_cast<::grpc::ServerContext*>(param.server_context)); ResponseType rsp; - ::grpc::Status status = - CatchingFunctionHandler([this, ¶m, &reader, &rsp] { - return func_( - service_, - static_cast<::grpc::ServerContext*>(param.server_context), - &reader, &rsp); - }); + ::grpc::Status status = CatchingFunctionHandler([this, ¶m, &reader, + &rsp] { + return func_(service_, + static_cast<::grpc::ServerContext*>(param.server_context), + &reader, &rsp); + }); ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, ::grpc::internal::CallOpSendMessage, @@ -188,10 +185,9 @@ class ServerStreamingHandler : public ::grpc::internal::MethodHandler { param.call, static_cast<::grpc::ServerContext*>(param.server_context)); status = CatchingFunctionHandler([this, ¶m, &writer] { - return func_( - service_, - static_cast<::grpc::ServerContext*>(param.server_context), - static_cast(param.request), &writer); + return func_(service_, + static_cast<::grpc::ServerContext*>(param.server_context), + static_cast(param.request), &writer); }); static_cast(param.request)->~RequestType(); } @@ -250,17 +246,15 @@ template class TemplatedBidiStreamingHandler : public ::grpc::internal::MethodHandler { public: TemplatedBidiStreamingHandler( - std::function<::grpc::Status(::grpc::ServerContext*, Streamer*)> - func) + std::function<::grpc::Status(::grpc::ServerContext*, Streamer*)> func) : func_(func), write_needed_(WriteNeeded) {} void RunHandler(const HandlerParameter& param) final { - Streamer stream(param.call, static_cast<::grpc::ServerContext*>( - param.server_context)); + Streamer stream(param.call, + static_cast<::grpc::ServerContext*>(param.server_context)); ::grpc::Status status = CatchingFunctionHandler([this, ¶m, &stream] { - return func_( - static_cast<::grpc::ServerContext*>(param.server_context), - &stream); + return func_(static_cast<::grpc::ServerContext*>(param.server_context), + &stream); }); ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, diff --git a/include/grpcpp/impl/codegen/rpc_service_method.h b/include/grpcpp/impl/codegen/rpc_service_method.h index d98b3ae0b1e..4fcc2112435 100644 --- a/include/grpcpp/impl/codegen/rpc_service_method.h +++ b/include/grpcpp/impl/codegen/rpc_service_method.h @@ -49,8 +49,8 @@ class MethodHandler { /// \param requester : used only by the callback API. It is a function /// called by the RPC Controller to request another RPC (and also /// to set up the state required to make that request possible) - HandlerParameter(Call* c, ::grpc::ServerContextBase* context, - void* req, Status req_status, void* handler_data, + HandlerParameter(Call* c, ::grpc::ServerContextBase* context, void* req, + Status req_status, void* handler_data, std::function requester) : call(c), server_context(context), diff --git a/include/grpcpp/impl/codegen/server_callback_handlers.h b/include/grpcpp/impl/codegen/server_callback_handlers.h index f1dd80a96f0..bd85e079f1b 100644 --- a/include/grpcpp/impl/codegen/server_callback_handlers.h +++ b/include/grpcpp/impl/codegen/server_callback_handlers.h @@ -52,8 +52,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler { auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( param.call->call(), sizeof(ServerCallbackUnaryImpl))) ServerCallbackUnaryImpl( - static_cast<::grpc::CallbackServerContext*>( - param.server_context), + static_cast<::grpc::CallbackServerContext*>(param.server_context), param.call, allocator_state, std::move(param.call_requester)); param.server_context->BeginCompletionOp( param.call, [call](bool) { call->MaybeDone(); }, call); @@ -62,8 +61,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler { if (param.status.ok()) { reactor = ::grpc::internal::CatchingReactorGetter( get_reactor_, - static_cast<::grpc::CallbackServerContext*>( - param.server_context), + static_cast<::grpc::CallbackServerContext*>(param.server_context), call->request(), call->response()); } @@ -266,8 +264,7 @@ class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { auto* reader = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( param.call->call(), sizeof(ServerCallbackReaderImpl))) ServerCallbackReaderImpl( - static_cast<::grpc::CallbackServerContext*>( - param.server_context), + static_cast<::grpc::CallbackServerContext*>(param.server_context), param.call, std::move(param.call_requester)); // Inlineable OnDone can be false in the CompletionOp callback because there // is no read reactor that has an inlineable OnDone; this only applies to @@ -282,8 +279,7 @@ class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { reactor = ::grpc::internal::CatchingReactorGetter< ServerReadReactor>( get_reactor_, - static_cast<::grpc::CallbackServerContext*>( - param.server_context), + static_cast<::grpc::CallbackServerContext*>(param.server_context), reader->response()); } @@ -299,8 +295,8 @@ class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler { } private: - std::function*( - ::grpc::CallbackServerContext*, ResponseType*)> + std::function*(::grpc::CallbackServerContext*, + ResponseType*)> get_reactor_; class ServerCallbackReaderImpl : public ServerCallbackReader { @@ -451,8 +447,7 @@ class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( param.call->call(), sizeof(ServerCallbackWriterImpl))) ServerCallbackWriterImpl( - static_cast<::grpc::CallbackServerContext*>( - param.server_context), + static_cast<::grpc::CallbackServerContext*>(param.server_context), param.call, static_cast(param.request), std::move(param.call_requester)); // Inlineable OnDone can be false in the CompletionOp callback because there @@ -468,8 +463,7 @@ class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler { reactor = ::grpc::internal::CatchingReactorGetter< ServerWriteReactor>( get_reactor_, - static_cast<::grpc::CallbackServerContext*>( - param.server_context), + static_cast<::grpc::CallbackServerContext*>(param.server_context), writer->request()); } if (reactor == nullptr) { @@ -671,8 +665,7 @@ class CallbackBidiHandler : public ::grpc::internal::MethodHandler { auto* stream = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) ServerCallbackReaderWriterImpl( - static_cast<::grpc::CallbackServerContext*>( - param.server_context), + static_cast<::grpc::CallbackServerContext*>(param.server_context), param.call, std::move(param.call_requester)); // Inlineable OnDone can be false in the CompletionOp callback because there // is no bidi reactor that has an inlineable OnDone; this only applies to @@ -686,8 +679,8 @@ class CallbackBidiHandler : public ::grpc::internal::MethodHandler { if (param.status.ok()) { reactor = ::grpc::internal::CatchingReactorGetter< ServerBidiReactor>( - get_reactor_, static_cast<::grpc::CallbackServerContext*>( - param.server_context)); + get_reactor_, + static_cast<::grpc::CallbackServerContext*>(param.server_context)); } if (reactor == nullptr) { diff --git a/include/grpcpp/impl/codegen/server_context.h b/include/grpcpp/impl/codegen/server_context.h index 59fa12c2815..209adfee16b 100644 --- a/include/grpcpp/impl/codegen/server_context.h +++ b/include/grpcpp/impl/codegen/server_context.h @@ -49,7 +49,6 @@ struct grpc_call; struct census_context; namespace grpc_impl { -class ClientContext; class Server; template class ServerAsyncReader; @@ -94,10 +93,19 @@ class ErrorMethodHandler; } // namespace grpc_impl namespace grpc { +class ClientContext; class CompletionQueue; class GenericServerContext; class ServerInterface; +// TODO(vjpai): Remove namespace experimental when de-experimentalized fully. +namespace experimental { + +typedef ::grpc::ServerContextBase ServerContextBase; +typedef ::grpc::CallbackServerContext CallbackServerContext; + +} // namespace experimental + #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL namespace experimental { #endif @@ -369,7 +377,7 @@ class ServerContextBase { friend class ::grpc_impl::internal::ErrorMethodHandler; template friend class ::grpc_impl::internal::FinishOnlyReactor; - friend class ::grpc_impl::ClientContext; + friend class ::grpc::ClientContext; friend class ::grpc::GenericServerContext; #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL friend class ::grpc::GenericCallbackServerContext; @@ -592,9 +600,9 @@ class CallbackServerContext : public ServerContextBase { } // namespace grpc -static_assert(std::is_base_of<::grpc::ServerContextBase, - ::grpc::ServerContext>::value, - "improper base class"); +static_assert( + std::is_base_of<::grpc::ServerContextBase, ::grpc::ServerContext>::value, + "improper base class"); static_assert(std::is_base_of<::grpc::ServerContextBase, ::grpc::CallbackServerContext>::value, "improper base class"); diff --git a/include/grpcpp/impl/codegen/server_interface.h b/include/grpcpp/impl/codegen/server_interface.h index e5f133d146b..fef2dc7edfa 100644 --- a/include/grpcpp/impl/codegen/server_interface.h +++ b/include/grpcpp/impl/codegen/server_interface.h @@ -191,8 +191,7 @@ class ServerInterface : public internal::CallHook { class BaseAsyncRequest : public internal::CompletionQueueTag { public: - BaseAsyncRequest(ServerInterface* server, - ::grpc::ServerContext* context, + BaseAsyncRequest(ServerInterface* server, ::grpc::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, void* tag, @@ -270,8 +269,7 @@ class ServerInterface : public internal::CallHook { class PayloadAsyncRequest final : public RegisteredAsyncRequest { public: PayloadAsyncRequest(internal::RpcServiceMethod* registered_method, - ServerInterface* server, - ::grpc::ServerContext* context, + ServerInterface* server, ::grpc::ServerContext* context, internal::ServerAsyncStreamingInterface* stream, ::grpc::CompletionQueue* call_cq, ::grpc::ServerCompletionQueue* notification_cq, diff --git a/include/grpcpp/impl/codegen/sync_stream_impl.h b/include/grpcpp/impl/codegen/sync_stream_impl.h index 286b28ae3f4..ce1ab11db19 100644 --- a/include/grpcpp/impl/codegen/sync_stream_impl.h +++ b/include/grpcpp/impl/codegen/sync_stream_impl.h @@ -707,8 +707,7 @@ namespace internal { template class ServerReaderWriterBody final { public: - ServerReaderWriterBody(grpc::internal::Call* call, - ::grpc::ServerContext* ctx) + ServerReaderWriterBody(grpc::internal::Call* call, ::grpc::ServerContext* ctx) : call_(call), ctx_(ctx) {} void SendInitialMetadata() { @@ -805,8 +804,7 @@ class ServerReaderWriter final : public ServerReaderWriterInterface { friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerReaderWriter, false>; - ServerReaderWriter(::grpc::internal::Call* call, - ::grpc::ServerContext* ctx) + ServerReaderWriter(::grpc::internal::Call* call, ::grpc::ServerContext* ctx) : body_(call, ctx) {} }; @@ -875,8 +873,7 @@ class ServerUnaryStreamer final friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerUnaryStreamer, true>; - ServerUnaryStreamer(::grpc::internal::Call* call, - ::grpc::ServerContext* ctx) + ServerUnaryStreamer(::grpc::internal::Call* call, ::grpc::ServerContext* ctx) : body_(call, ctx), read_done_(false), write_done_(false) {} }; @@ -937,8 +934,7 @@ class ServerSplitStreamer final friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< ServerSplitStreamer, false>; - ServerSplitStreamer(::grpc::internal::Call* call, - ::grpc::ServerContext* ctx) + ServerSplitStreamer(::grpc::internal::Call* call, ::grpc::ServerContext* ctx) : body_(call, ctx), read_done_(false) {} }; diff --git a/src/cpp/client/client_context.cc b/src/cpp/client/client_context.cc index e70d57c5f6d..29e11200f5a 100644 --- a/src/cpp/client/client_context.cc +++ b/src/cpp/client/client_context.cc @@ -97,8 +97,7 @@ std::unique_ptr ClientContext::FromInternalServerContext( } std::unique_ptr ClientContext::FromServerContext( - const grpc::ServerContext& server_context, - PropagationOptions options) { + const grpc::ServerContext& server_context, PropagationOptions options) { return FromInternalServerContext(server_context, options); }