Fix and format build after rebase

pull/23916/head
Karthik Ravi Shankar 5 years ago
parent dc3e1097e9
commit a23578444c
  1. 13
      include/grpcpp/impl/codegen/client_context.h
  2. 42
      include/grpcpp/impl/codegen/method_handler_impl.h
  3. 4
      include/grpcpp/impl/codegen/rpc_service_method.h
  4. 29
      include/grpcpp/impl/codegen/server_callback_handlers.h
  5. 18
      include/grpcpp/impl/codegen/server_context.h
  6. 6
      include/grpcpp/impl/codegen/server_interface.h
  7. 12
      include/grpcpp/impl/codegen/sync_stream_impl.h
  8. 3
      src/cpp/client/client_context.cc

@ -71,7 +71,6 @@ class ClientCallbackUnaryImpl;
class ClientContextAccessor; class ClientContextAccessor;
} // namespace internal } // namespace internal
class ServerContext;
template <class R> template <class R>
class ClientReader; class ClientReader;
template <class W> template <class W>
@ -87,12 +86,14 @@ class ClientAsyncReaderWriter;
template <class R> template <class R>
class ClientAsyncResponseReader; class ClientAsyncResponseReader;
class ServerContextBase;
class CallbackServerContext;
} // namespace grpc_impl } // namespace grpc_impl
namespace grpc { namespace grpc {
class ServerContext;
class ServerContextBase;
class CallbackServerContext;
namespace testing { namespace testing {
class InteropClientContextInspector; class InteropClientContextInspector;
} // namespace testing } // namespace testing
@ -208,10 +209,10 @@ class ClientContext {
/// \return A newly constructed \a ClientContext instance based on \a /// \return A newly constructed \a ClientContext instance based on \a
/// server_context, with traits propagated (copied) according to \a options. /// server_context, with traits propagated (copied) according to \a options.
static std::unique_ptr<ClientContext> FromServerContext( static std::unique_ptr<ClientContext> FromServerContext(
const grpc_impl::ServerContext& server_context, const grpc::ServerContext& server_context,
PropagationOptions options = PropagationOptions()); PropagationOptions options = PropagationOptions());
static std::unique_ptr<ClientContext> FromCallbackServerContext( static std::unique_ptr<ClientContext> FromCallbackServerContext(
const grpc_impl::CallbackServerContext& server_context, const grpc::CallbackServerContext& server_context,
PropagationOptions options = PropagationOptions()); PropagationOptions options = PropagationOptions());
/// Add the (\a meta_key, \a meta_value) pair to the metadata associated with /// Add the (\a meta_key, \a meta_value) pair to the metadata associated with
@ -491,7 +492,7 @@ class ClientContext {
void SendCancelToInterceptors(); void SendCancelToInterceptors();
static std::unique_ptr<ClientContext> FromInternalServerContext( static std::unique_ptr<ClientContext> FromInternalServerContext(
const grpc_impl::ServerContextBase& server_context, const grpc::ServerContextBase& server_context,
PropagationOptions options); PropagationOptions options);
bool initial_metadata_received_; bool initial_metadata_received_;

@ -65,10 +65,9 @@ class RpcMethodHandler : public ::grpc::internal::MethodHandler {
::grpc::Status status = param.status; ::grpc::Status status = param.status;
if (status.ok()) { if (status.ok()) {
status = CatchingFunctionHandler([this, &param, &rsp] { status = CatchingFunctionHandler([this, &param, &rsp] {
return func_( return func_(service_,
service_, static_cast<::grpc::ServerContext*>(param.server_context),
static_cast<::grpc::ServerContext*>(param.server_context), static_cast<RequestType*>(param.request), &rsp);
static_cast<RequestType*>(param.request), &rsp);
}); });
static_cast<RequestType*>(param.request)->~RequestType(); static_cast<RequestType*>(param.request)->~RequestType();
} }
@ -131,16 +130,14 @@ class ClientStreamingHandler : public ::grpc::internal::MethodHandler {
void RunHandler(const HandlerParameter& param) final { void RunHandler(const HandlerParameter& param) final {
::grpc_impl::ServerReader<RequestType> reader( ::grpc_impl::ServerReader<RequestType> reader(
param.call, param.call, static_cast<::grpc::ServerContext*>(param.server_context));
static_cast<::grpc::ServerContext*>(param.server_context));
ResponseType rsp; ResponseType rsp;
::grpc::Status status = ::grpc::Status status = CatchingFunctionHandler([this, &param, &reader,
CatchingFunctionHandler([this, &param, &reader, &rsp] { &rsp] {
return func_( return func_(service_,
service_, static_cast<::grpc::ServerContext*>(param.server_context),
static_cast<::grpc::ServerContext*>(param.server_context), &reader, &rsp);
&reader, &rsp); });
});
::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,
::grpc::internal::CallOpSendMessage, ::grpc::internal::CallOpSendMessage,
@ -188,10 +185,9 @@ class ServerStreamingHandler : public ::grpc::internal::MethodHandler {
param.call, param.call,
static_cast<::grpc::ServerContext*>(param.server_context)); static_cast<::grpc::ServerContext*>(param.server_context));
status = CatchingFunctionHandler([this, &param, &writer] { status = CatchingFunctionHandler([this, &param, &writer] {
return func_( return func_(service_,
service_, static_cast<::grpc::ServerContext*>(param.server_context),
static_cast<::grpc::ServerContext*>(param.server_context), static_cast<RequestType*>(param.request), &writer);
static_cast<RequestType*>(param.request), &writer);
}); });
static_cast<RequestType*>(param.request)->~RequestType(); static_cast<RequestType*>(param.request)->~RequestType();
} }
@ -250,17 +246,15 @@ template <class Streamer, bool WriteNeeded>
class TemplatedBidiStreamingHandler : public ::grpc::internal::MethodHandler { class TemplatedBidiStreamingHandler : public ::grpc::internal::MethodHandler {
public: public:
TemplatedBidiStreamingHandler( TemplatedBidiStreamingHandler(
std::function<::grpc::Status(::grpc::ServerContext*, Streamer*)> std::function<::grpc::Status(::grpc::ServerContext*, Streamer*)> func)
func)
: func_(func), write_needed_(WriteNeeded) {} : func_(func), write_needed_(WriteNeeded) {}
void RunHandler(const HandlerParameter& param) final { void RunHandler(const HandlerParameter& param) final {
Streamer stream(param.call, static_cast<::grpc::ServerContext*>( Streamer stream(param.call,
param.server_context)); static_cast<::grpc::ServerContext*>(param.server_context));
::grpc::Status status = CatchingFunctionHandler([this, &param, &stream] { ::grpc::Status status = CatchingFunctionHandler([this, &param, &stream] {
return func_( return func_(static_cast<::grpc::ServerContext*>(param.server_context),
static_cast<::grpc::ServerContext*>(param.server_context), &stream);
&stream);
}); });
::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata, ::grpc::internal::CallOpSet<::grpc::internal::CallOpSendInitialMetadata,

@ -49,8 +49,8 @@ class MethodHandler {
/// \param requester : used only by the callback API. It is a function /// \param requester : used only by the callback API. It is a function
/// called by the RPC Controller to request another RPC (and also /// called by the RPC Controller to request another RPC (and also
/// to set up the state required to make that request possible) /// to set up the state required to make that request possible)
HandlerParameter(Call* c, ::grpc::ServerContextBase* context, HandlerParameter(Call* c, ::grpc::ServerContextBase* context, void* req,
void* req, Status req_status, void* handler_data, Status req_status, void* handler_data,
std::function<void()> requester) std::function<void()> requester)
: call(c), : call(c),
server_context(context), server_context(context),

@ -52,8 +52,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler {
auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( auto* call = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
param.call->call(), sizeof(ServerCallbackUnaryImpl))) param.call->call(), sizeof(ServerCallbackUnaryImpl)))
ServerCallbackUnaryImpl( ServerCallbackUnaryImpl(
static_cast<::grpc::CallbackServerContext*>( static_cast<::grpc::CallbackServerContext*>(param.server_context),
param.server_context),
param.call, allocator_state, std::move(param.call_requester)); param.call, allocator_state, std::move(param.call_requester));
param.server_context->BeginCompletionOp( param.server_context->BeginCompletionOp(
param.call, [call](bool) { call->MaybeDone(); }, call); param.call, [call](bool) { call->MaybeDone(); }, call);
@ -62,8 +61,7 @@ class CallbackUnaryHandler : public ::grpc::internal::MethodHandler {
if (param.status.ok()) { if (param.status.ok()) {
reactor = ::grpc::internal::CatchingReactorGetter<ServerUnaryReactor>( reactor = ::grpc::internal::CatchingReactorGetter<ServerUnaryReactor>(
get_reactor_, get_reactor_,
static_cast<::grpc::CallbackServerContext*>( static_cast<::grpc::CallbackServerContext*>(param.server_context),
param.server_context),
call->request(), call->response()); 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( auto* reader = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
param.call->call(), sizeof(ServerCallbackReaderImpl))) param.call->call(), sizeof(ServerCallbackReaderImpl)))
ServerCallbackReaderImpl( ServerCallbackReaderImpl(
static_cast<::grpc::CallbackServerContext*>( static_cast<::grpc::CallbackServerContext*>(param.server_context),
param.server_context),
param.call, std::move(param.call_requester)); param.call, std::move(param.call_requester));
// Inlineable OnDone can be false in the CompletionOp callback because there // Inlineable OnDone can be false in the CompletionOp callback because there
// is no read reactor that has an inlineable OnDone; this only applies to // 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< reactor = ::grpc::internal::CatchingReactorGetter<
ServerReadReactor<RequestType>>( ServerReadReactor<RequestType>>(
get_reactor_, get_reactor_,
static_cast<::grpc::CallbackServerContext*>( static_cast<::grpc::CallbackServerContext*>(param.server_context),
param.server_context),
reader->response()); reader->response());
} }
@ -299,8 +295,8 @@ class CallbackClientStreamingHandler : public ::grpc::internal::MethodHandler {
} }
private: private:
std::function<ServerReadReactor<RequestType>*( std::function<ServerReadReactor<RequestType>*(::grpc::CallbackServerContext*,
::grpc::CallbackServerContext*, ResponseType*)> ResponseType*)>
get_reactor_; get_reactor_;
class ServerCallbackReaderImpl : public ServerCallbackReader<RequestType> { class ServerCallbackReaderImpl : public ServerCallbackReader<RequestType> {
@ -451,8 +447,7 @@ class CallbackServerStreamingHandler : public ::grpc::internal::MethodHandler {
auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc( auto* writer = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
param.call->call(), sizeof(ServerCallbackWriterImpl))) param.call->call(), sizeof(ServerCallbackWriterImpl)))
ServerCallbackWriterImpl( ServerCallbackWriterImpl(
static_cast<::grpc::CallbackServerContext*>( static_cast<::grpc::CallbackServerContext*>(param.server_context),
param.server_context),
param.call, static_cast<RequestType*>(param.request), param.call, static_cast<RequestType*>(param.request),
std::move(param.call_requester)); std::move(param.call_requester));
// Inlineable OnDone can be false in the CompletionOp callback because there // 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< reactor = ::grpc::internal::CatchingReactorGetter<
ServerWriteReactor<ResponseType>>( ServerWriteReactor<ResponseType>>(
get_reactor_, get_reactor_,
static_cast<::grpc::CallbackServerContext*>( static_cast<::grpc::CallbackServerContext*>(param.server_context),
param.server_context),
writer->request()); writer->request());
} }
if (reactor == nullptr) { 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( auto* stream = new (::grpc::g_core_codegen_interface->grpc_call_arena_alloc(
param.call->call(), sizeof(ServerCallbackReaderWriterImpl))) param.call->call(), sizeof(ServerCallbackReaderWriterImpl)))
ServerCallbackReaderWriterImpl( ServerCallbackReaderWriterImpl(
static_cast<::grpc::CallbackServerContext*>( static_cast<::grpc::CallbackServerContext*>(param.server_context),
param.server_context),
param.call, std::move(param.call_requester)); param.call, std::move(param.call_requester));
// Inlineable OnDone can be false in the CompletionOp callback because there // Inlineable OnDone can be false in the CompletionOp callback because there
// is no bidi reactor that has an inlineable OnDone; this only applies to // 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()) { if (param.status.ok()) {
reactor = ::grpc::internal::CatchingReactorGetter< reactor = ::grpc::internal::CatchingReactorGetter<
ServerBidiReactor<RequestType, ResponseType>>( ServerBidiReactor<RequestType, ResponseType>>(
get_reactor_, static_cast<::grpc::CallbackServerContext*>( get_reactor_,
param.server_context)); static_cast<::grpc::CallbackServerContext*>(param.server_context));
} }
if (reactor == nullptr) { if (reactor == nullptr) {

@ -49,7 +49,6 @@ struct grpc_call;
struct census_context; struct census_context;
namespace grpc_impl { namespace grpc_impl {
class ClientContext;
class Server; class Server;
template <class W, class R> template <class W, class R>
class ServerAsyncReader; class ServerAsyncReader;
@ -94,10 +93,19 @@ class ErrorMethodHandler;
} // namespace grpc_impl } // namespace grpc_impl
namespace grpc { namespace grpc {
class ClientContext;
class CompletionQueue; class CompletionQueue;
class GenericServerContext; class GenericServerContext;
class ServerInterface; 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 #ifndef GRPC_CALLBACK_API_NONEXPERIMENTAL
namespace experimental { namespace experimental {
#endif #endif
@ -369,7 +377,7 @@ class ServerContextBase {
friend class ::grpc_impl::internal::ErrorMethodHandler; friend class ::grpc_impl::internal::ErrorMethodHandler;
template <class Base> template <class Base>
friend class ::grpc_impl::internal::FinishOnlyReactor; friend class ::grpc_impl::internal::FinishOnlyReactor;
friend class ::grpc_impl::ClientContext; friend class ::grpc::ClientContext;
friend class ::grpc::GenericServerContext; friend class ::grpc::GenericServerContext;
#ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL #ifdef GRPC_CALLBACK_API_NONEXPERIMENTAL
friend class ::grpc::GenericCallbackServerContext; friend class ::grpc::GenericCallbackServerContext;
@ -592,9 +600,9 @@ class CallbackServerContext : public ServerContextBase {
} // namespace grpc } // namespace grpc
static_assert(std::is_base_of<::grpc::ServerContextBase, static_assert(
::grpc::ServerContext>::value, std::is_base_of<::grpc::ServerContextBase, ::grpc::ServerContext>::value,
"improper base class"); "improper base class");
static_assert(std::is_base_of<::grpc::ServerContextBase, static_assert(std::is_base_of<::grpc::ServerContextBase,
::grpc::CallbackServerContext>::value, ::grpc::CallbackServerContext>::value,
"improper base class"); "improper base class");

@ -191,8 +191,7 @@ class ServerInterface : public internal::CallHook {
class BaseAsyncRequest : public internal::CompletionQueueTag { class BaseAsyncRequest : public internal::CompletionQueueTag {
public: public:
BaseAsyncRequest(ServerInterface* server, BaseAsyncRequest(ServerInterface* server, ::grpc::ServerContext* context,
::grpc::ServerContext* context,
internal::ServerAsyncStreamingInterface* stream, internal::ServerAsyncStreamingInterface* stream,
::grpc::CompletionQueue* call_cq, ::grpc::CompletionQueue* call_cq,
::grpc::ServerCompletionQueue* notification_cq, void* tag, ::grpc::ServerCompletionQueue* notification_cq, void* tag,
@ -270,8 +269,7 @@ class ServerInterface : public internal::CallHook {
class PayloadAsyncRequest final : public RegisteredAsyncRequest { class PayloadAsyncRequest final : public RegisteredAsyncRequest {
public: public:
PayloadAsyncRequest(internal::RpcServiceMethod* registered_method, PayloadAsyncRequest(internal::RpcServiceMethod* registered_method,
ServerInterface* server, ServerInterface* server, ::grpc::ServerContext* context,
::grpc::ServerContext* context,
internal::ServerAsyncStreamingInterface* stream, internal::ServerAsyncStreamingInterface* stream,
::grpc::CompletionQueue* call_cq, ::grpc::CompletionQueue* call_cq,
::grpc::ServerCompletionQueue* notification_cq, ::grpc::ServerCompletionQueue* notification_cq,

@ -707,8 +707,7 @@ namespace internal {
template <class W, class R> template <class W, class R>
class ServerReaderWriterBody final { class ServerReaderWriterBody final {
public: public:
ServerReaderWriterBody(grpc::internal::Call* call, ServerReaderWriterBody(grpc::internal::Call* call, ::grpc::ServerContext* ctx)
::grpc::ServerContext* ctx)
: call_(call), ctx_(ctx) {} : call_(call), ctx_(ctx) {}
void SendInitialMetadata() { void SendInitialMetadata() {
@ -805,8 +804,7 @@ class ServerReaderWriter final : public ServerReaderWriterInterface<W, R> {
friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler<
ServerReaderWriter<W, R>, false>; ServerReaderWriter<W, R>, false>;
ServerReaderWriter(::grpc::internal::Call* call, ServerReaderWriter(::grpc::internal::Call* call, ::grpc::ServerContext* ctx)
::grpc::ServerContext* ctx)
: body_(call, ctx) {} : body_(call, ctx) {}
}; };
@ -875,8 +873,7 @@ class ServerUnaryStreamer final
friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler<
ServerUnaryStreamer<RequestType, ResponseType>, true>; ServerUnaryStreamer<RequestType, ResponseType>, true>;
ServerUnaryStreamer(::grpc::internal::Call* call, ServerUnaryStreamer(::grpc::internal::Call* call, ::grpc::ServerContext* ctx)
::grpc::ServerContext* ctx)
: body_(call, ctx), read_done_(false), write_done_(false) {} : body_(call, ctx), read_done_(false), write_done_(false) {}
}; };
@ -937,8 +934,7 @@ class ServerSplitStreamer final
friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler< friend class ::grpc_impl::internal::TemplatedBidiStreamingHandler<
ServerSplitStreamer<RequestType, ResponseType>, false>; ServerSplitStreamer<RequestType, ResponseType>, false>;
ServerSplitStreamer(::grpc::internal::Call* call, ServerSplitStreamer(::grpc::internal::Call* call, ::grpc::ServerContext* ctx)
::grpc::ServerContext* ctx)
: body_(call, ctx), read_done_(false) {} : body_(call, ctx), read_done_(false) {}
}; };

@ -97,8 +97,7 @@ std::unique_ptr<ClientContext> ClientContext::FromInternalServerContext(
} }
std::unique_ptr<ClientContext> ClientContext::FromServerContext( std::unique_ptr<ClientContext> ClientContext::FromServerContext(
const grpc::ServerContext& server_context, const grpc::ServerContext& server_context, PropagationOptions options) {
PropagationOptions options) {
return FromInternalServerContext(server_context, options); return FromInternalServerContext(server_context, options);
} }

Loading…
Cancel
Save