Skip to content

Commit

Permalink
Merge pull request grpc#19236 from mhaidrygoog/move_server_context
Browse files Browse the repository at this point in the history
Move server context implementation to grpc_impl namespace and typedef…
  • Loading branch information
mhaidrygoog committed Jun 12, 2019
2 parents 345caa1 + 1868753 commit 465eb2f
Show file tree
Hide file tree
Showing 26 changed files with 489 additions and 430 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,5 @@ bm_*.json
!.vscode/launch.json
!.vscode/extensions.json

# Clion artifacts
cmake-build-debug/
1 change: 1 addition & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2186,6 +2186,7 @@ grpc_cc_library(
"include/grpcpp/impl/codegen/serialization_traits.h",
"include/grpcpp/impl/codegen/server_callback.h",
"include/grpcpp/impl/codegen/server_context.h",
"include/grpcpp/impl/codegen/server_context_impl.h",
"include/grpcpp/impl/codegen/server_interceptor.h",
"include/grpcpp/impl/codegen/server_interface.h",
"include/grpcpp/impl/codegen/service_type.h",
Expand Down
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ config("grpc_config") {
"include/grpcpp/impl/codegen/serialization_traits.h",
"include/grpcpp/impl/codegen/server_callback.h",
"include/grpcpp/impl/codegen/server_context.h",
"include/grpcpp/impl/codegen/server_context_impl.h",
"include/grpcpp/impl/codegen/server_interceptor.h",
"include/grpcpp/impl/codegen/server_interface.h",
"include/grpcpp/impl/codegen/service_type.h",
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3337,6 +3337,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/serialization_traits.h
include/grpcpp/impl/codegen/server_callback.h
include/grpcpp/impl/codegen/server_context.h
include/grpcpp/impl/codegen/server_context_impl.h
include/grpcpp/impl/codegen/server_interceptor.h
include/grpcpp/impl/codegen/server_interface.h
include/grpcpp/impl/codegen/service_type.h
Expand Down Expand Up @@ -3957,6 +3958,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/serialization_traits.h
include/grpcpp/impl/codegen/server_callback.h
include/grpcpp/impl/codegen/server_context.h
include/grpcpp/impl/codegen/server_context_impl.h
include/grpcpp/impl/codegen/server_interceptor.h
include/grpcpp/impl/codegen/server_interface.h
include/grpcpp/impl/codegen/service_type.h
Expand Down Expand Up @@ -4393,6 +4395,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/serialization_traits.h
include/grpcpp/impl/codegen/server_callback.h
include/grpcpp/impl/codegen/server_context.h
include/grpcpp/impl/codegen/server_context_impl.h
include/grpcpp/impl/codegen/server_interceptor.h
include/grpcpp/impl/codegen/server_interface.h
include/grpcpp/impl/codegen/service_type.h
Expand Down Expand Up @@ -4593,6 +4596,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/serialization_traits.h
include/grpcpp/impl/codegen/server_callback.h
include/grpcpp/impl/codegen/server_context.h
include/grpcpp/impl/codegen/server_context_impl.h
include/grpcpp/impl/codegen/server_interceptor.h
include/grpcpp/impl/codegen/server_interface.h
include/grpcpp/impl/codegen/service_type.h
Expand Down Expand Up @@ -4953,6 +4957,7 @@ foreach(_hdr
include/grpcpp/impl/codegen/serialization_traits.h
include/grpcpp/impl/codegen/server_callback.h
include/grpcpp/impl/codegen/server_context.h
include/grpcpp/impl/codegen/server_context_impl.h
include/grpcpp/impl/codegen/server_interceptor.h
include/grpcpp/impl/codegen/server_interface.h
include/grpcpp/impl/codegen/service_type.h
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5692,6 +5692,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/serialization_traits.h \
include/grpcpp/impl/codegen/server_callback.h \
include/grpcpp/impl/codegen/server_context.h \
include/grpcpp/impl/codegen/server_context_impl.h \
include/grpcpp/impl/codegen/server_interceptor.h \
include/grpcpp/impl/codegen/server_interface.h \
include/grpcpp/impl/codegen/service_type.h \
Expand Down Expand Up @@ -6320,6 +6321,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/serialization_traits.h \
include/grpcpp/impl/codegen/server_callback.h \
include/grpcpp/impl/codegen/server_context.h \
include/grpcpp/impl/codegen/server_context_impl.h \
include/grpcpp/impl/codegen/server_interceptor.h \
include/grpcpp/impl/codegen/server_interface.h \
include/grpcpp/impl/codegen/service_type.h \
Expand Down Expand Up @@ -6728,6 +6730,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/serialization_traits.h \
include/grpcpp/impl/codegen/server_callback.h \
include/grpcpp/impl/codegen/server_context.h \
include/grpcpp/impl/codegen/server_context_impl.h \
include/grpcpp/impl/codegen/server_interceptor.h \
include/grpcpp/impl/codegen/server_interface.h \
include/grpcpp/impl/codegen/service_type.h \
Expand Down Expand Up @@ -6899,6 +6902,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/serialization_traits.h \
include/grpcpp/impl/codegen/server_callback.h \
include/grpcpp/impl/codegen/server_context.h \
include/grpcpp/impl/codegen/server_context_impl.h \
include/grpcpp/impl/codegen/server_interceptor.h \
include/grpcpp/impl/codegen/server_interface.h \
include/grpcpp/impl/codegen/service_type.h \
Expand Down Expand Up @@ -7265,6 +7269,7 @@ PUBLIC_HEADERS_CXX += \
include/grpcpp/impl/codegen/serialization_traits.h \
include/grpcpp/impl/codegen/server_callback.h \
include/grpcpp/impl/codegen/server_context.h \
include/grpcpp/impl/codegen/server_context_impl.h \
include/grpcpp/impl/codegen/server_interceptor.h \
include/grpcpp/impl/codegen/server_interface.h \
include/grpcpp/impl/codegen/service_type.h \
Expand Down
1 change: 1 addition & 0 deletions build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,7 @@ filegroups:
- include/grpcpp/impl/codegen/serialization_traits.h
- include/grpcpp/impl/codegen/server_callback.h
- include/grpcpp/impl/codegen/server_context.h
- include/grpcpp/impl/codegen/server_context_impl.h
- include/grpcpp/impl/codegen/server_interceptor.h
- include/grpcpp/impl/codegen/server_interface.h
- include/grpcpp/impl/codegen/service_type.h
Expand Down
1 change: 1 addition & 0 deletions gRPC-C++.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Pod::Spec.new do |s|
'include/grpcpp/impl/codegen/serialization_traits.h',
'include/grpcpp/impl/codegen/server_callback.h',
'include/grpcpp/impl/codegen/server_context.h',
'include/grpcpp/impl/codegen/server_context_impl.h',
'include/grpcpp/impl/codegen/server_interceptor.h',
'include/grpcpp/impl/codegen/server_interface.h',
'include/grpcpp/impl/codegen/service_type.h',
Expand Down
4 changes: 2 additions & 2 deletions include/grpcpp/impl/codegen/client_context_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ template <class W, class R>
class ClientAsyncReaderWriter;
template <class R>
class ClientAsyncResponseReader;
class ServerContext;

namespace testing {
class InteropClientContextInspector;
Expand All @@ -103,6 +102,7 @@ namespace grpc_impl {
class CallCredentials;
class Channel;
class CompletionQueue;
class ServerContext;

/// Options for \a ClientContext::FromServerContext specifying which traits from
/// the \a ServerContext to propagate (copy) from it into a new \a
Expand Down Expand Up @@ -191,7 +191,7 @@ 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<ClientContext> FromServerContext(
const grpc::ServerContext& server_context,
const grpc_impl::ServerContext& server_context,
PropagationOptions options = PropagationOptions());

/// Add the (\a meta_key, \a meta_value) pair to the metadata associated with
Expand Down
4 changes: 2 additions & 2 deletions include/grpcpp/impl/codegen/completion_queue_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace grpc_impl {
class Channel;
class Server;
class ServerBuilder;
class ServerContext;
} // namespace grpc_impl
namespace grpc {

Expand All @@ -65,7 +66,6 @@ class ServerReaderWriterBody;
} // namespace internal

class ChannelInterface;
class ServerContext;
class ServerInterface;

namespace internal {
Expand Down Expand Up @@ -277,7 +277,7 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen {
template <::grpc::StatusCode code>
friend class ::grpc::internal::ErrorMethodHandler;
friend class ::grpc_impl::Server;
friend class ::grpc::ServerContext;
friend class ::grpc_impl::ServerContext;
friend class ::grpc::ServerInterface;
template <class InputMessage, class OutputMessage>
friend class ::grpc::internal::BlockingUnaryCallImpl;
Expand Down
8 changes: 5 additions & 3 deletions include/grpcpp/impl/codegen/rpc_service_method.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
#include <grpcpp/impl/codegen/rpc_method.h>
#include <grpcpp/impl/codegen/status.h>

namespace grpc {
namespace grpc_impl {
class ServerContext;
}

namespace grpc {
namespace internal {
/// Base class for running an RPC handler.
class MethodHandler {
Expand All @@ -50,7 +52,7 @@ 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, ServerContext* context, void* req,
HandlerParameter(Call* c, ::grpc_impl::ServerContext* context, void* req,
Status req_status, void* handler_data,
std::function<void()> requester)
: call(c),
Expand All @@ -61,7 +63,7 @@ class MethodHandler {
call_requester(std::move(requester)) {}
~HandlerParameter() {}
Call* call;
ServerContext* server_context;
::grpc_impl::ServerContext* server_context;
void* request;
Status status;
void* internal_data;
Expand Down
42 changes: 23 additions & 19 deletions include/grpcpp/impl/codegen/server_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <grpcpp/impl/codegen/config.h>
#include <grpcpp/impl/codegen/core_codegen_interface.h>
#include <grpcpp/impl/codegen/message_allocator.h>
#include <grpcpp/impl/codegen/server_context.h>
#include <grpcpp/impl/codegen/server_context_impl.h>
#include <grpcpp/impl/codegen/server_interface.h>
#include <grpcpp/impl/codegen/status.h>

Expand All @@ -53,7 +53,7 @@ class ServerReactor {
virtual void OnCancel() = 0;

private:
friend class ::grpc::ServerContext;
friend class ::grpc_impl::ServerContext;
template <class Request, class Response>
friend class CallbackClientStreamingHandler;
template <class Request, class Response>
Expand Down Expand Up @@ -313,7 +313,7 @@ class ServerBidiReactor : public internal::ServerReactor {
/// is a result of the client calling StartCall().
///
/// \param[in] context The context object now associated with this RPC
virtual void OnStarted(ServerContext* context) {}
virtual void OnStarted(::grpc_impl::ServerContext* context) {}

/// Notifies the application that an explicit StartSendInitialMetadata
/// operation completed. Not used when the sending of initial metadata
Expand Down Expand Up @@ -372,7 +372,7 @@ class ServerReadReactor : public internal::ServerReactor {
///
/// \param[in] context The context object now associated with this RPC
/// \param[in] resp The response object to be used by this RPC
virtual void OnStarted(ServerContext* context, Response* resp) {}
virtual void OnStarted(::grpc_impl::ServerContext* context, Response* resp) {}

/// The following notifications are exactly like ServerBidiReactor.
virtual void OnSendInitialMetadataDone(bool ok) {}
Expand Down Expand Up @@ -413,7 +413,8 @@ class ServerWriteReactor : public internal::ServerReactor {
///
/// \param[in] context The context object now associated with this RPC
/// \param[in] req The request object sent by the client
virtual void OnStarted(ServerContext* context, const Request* req) {}
virtual void OnStarted(::grpc_impl::ServerContext* context,
const Request* req) {}

/// The following notifications are exactly like ServerBidiReactor.
virtual void OnSendInitialMetadataDone(bool ok) {}
Expand All @@ -437,7 +438,7 @@ class UnimplementedReadReactor
: public experimental::ServerReadReactor<Request, Response> {
public:
void OnDone() override { delete this; }
void OnStarted(ServerContext*, Response*) override {
void OnStarted(::grpc_impl::ServerContext*, Response*) override {
this->Finish(Status(StatusCode::UNIMPLEMENTED, ""));
}
};
Expand All @@ -447,7 +448,7 @@ class UnimplementedWriteReactor
: public experimental::ServerWriteReactor<Request, Response> {
public:
void OnDone() override { delete this; }
void OnStarted(ServerContext*, const Request*) override {
void OnStarted(::grpc_impl::ServerContext*, const Request*) override {
this->Finish(Status(StatusCode::UNIMPLEMENTED, ""));
}
};
Expand All @@ -457,7 +458,7 @@ class UnimplementedBidiReactor
: public experimental::ServerBidiReactor<Request, Response> {
public:
void OnDone() override { delete this; }
void OnStarted(ServerContext*) override {
void OnStarted(::grpc_impl::ServerContext*) override {
this->Finish(Status(StatusCode::UNIMPLEMENTED, ""));
}
};
Expand All @@ -466,7 +467,8 @@ template <class RequestType, class ResponseType>
class CallbackUnaryHandler : public MethodHandler {
public:
CallbackUnaryHandler(
std::function<void(ServerContext*, const RequestType*, ResponseType*,
std::function<void(::grpc_impl::ServerContext*, const RequestType*,
ResponseType*,
experimental::ServerCallbackRpcController*)>
func)
: func_(func) {}
Expand Down Expand Up @@ -525,8 +527,8 @@ class CallbackUnaryHandler : public MethodHandler {
}

private:
std::function<void(ServerContext*, const RequestType*, ResponseType*,
experimental::ServerCallbackRpcController*)>
std::function<void(::grpc_impl::ServerContext*, const RequestType*,
ResponseType*, experimental::ServerCallbackRpcController*)>
func_;
experimental::MessageAllocator<RequestType, ResponseType>* allocator_ =
nullptr;
Expand Down Expand Up @@ -597,7 +599,7 @@ class CallbackUnaryHandler : public MethodHandler {
friend class CallbackUnaryHandler<RequestType, ResponseType>;

ServerCallbackRpcControllerImpl(
ServerContext* ctx, Call* call,
::grpc_impl::ServerContext* ctx, Call* call,
experimental::MessageHolder<RequestType, ResponseType>* allocator_state,
std::function<void()> call_requester)
: ctx_(ctx),
Expand Down Expand Up @@ -628,7 +630,7 @@ class CallbackUnaryHandler : public MethodHandler {
finish_ops_;
CallbackWithSuccessTag finish_tag_;

ServerContext* ctx_;
::grpc_impl::ServerContext* ctx_;
Call call_;
experimental::MessageHolder<RequestType, ResponseType>* const
allocator_state_;
Expand Down Expand Up @@ -732,7 +734,8 @@ class CallbackClientStreamingHandler : public MethodHandler {
friend class CallbackClientStreamingHandler<RequestType, ResponseType>;

ServerCallbackReaderImpl(
ServerContext* ctx, Call* call, std::function<void()> call_requester,
::grpc_impl::ServerContext* ctx, Call* call,
std::function<void()> call_requester,
experimental::ServerReadReactor<RequestType, ResponseType>* reactor)
: ctx_(ctx),
call_(*call),
Expand Down Expand Up @@ -772,7 +775,7 @@ class CallbackClientStreamingHandler : public MethodHandler {
CallOpSet<CallOpRecvMessage<RequestType>> read_ops_;
CallbackWithSuccessTag read_tag_;

ServerContext* ctx_;
::grpc_impl::ServerContext* ctx_;
Call call_;
ResponseType resp_;
std::function<void()> call_requester_;
Expand Down Expand Up @@ -909,7 +912,7 @@ class CallbackServerStreamingHandler : public MethodHandler {
friend class CallbackServerStreamingHandler<RequestType, ResponseType>;

ServerCallbackWriterImpl(
ServerContext* ctx, Call* call, const RequestType* req,
::grpc_impl::ServerContext* ctx, Call* call, const RequestType* req,
std::function<void()> call_requester,
experimental::ServerWriteReactor<RequestType, ResponseType>* reactor)
: ctx_(ctx),
Expand Down Expand Up @@ -950,7 +953,7 @@ class CallbackServerStreamingHandler : public MethodHandler {
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> write_ops_;
CallbackWithSuccessTag write_tag_;

ServerContext* ctx_;
::grpc_impl::ServerContext* ctx_;
Call call_;
const RequestType* req_;
std::function<void()> call_requester_;
Expand Down Expand Up @@ -1078,7 +1081,8 @@ class CallbackBidiHandler : public MethodHandler {
friend class CallbackBidiHandler<RequestType, ResponseType>;

ServerCallbackReaderWriterImpl(
ServerContext* ctx, Call* call, std::function<void()> call_requester,
::grpc_impl::ServerContext* ctx, Call* call,
std::function<void()> call_requester,
experimental::ServerBidiReactor<RequestType, ResponseType>* reactor)
: ctx_(ctx),
call_(*call),
Expand Down Expand Up @@ -1124,7 +1128,7 @@ class CallbackBidiHandler : public MethodHandler {
CallOpSet<CallOpRecvMessage<RequestType>> read_ops_;
CallbackWithSuccessTag read_tag_;

ServerContext* ctx_;
::grpc_impl::ServerContext* ctx_;
Call call_;
std::function<void()> call_requester_;
experimental::ServerBidiReactor<RequestType, ResponseType>* reactor_;
Expand Down
Loading

0 comments on commit 465eb2f

Please sign in to comment.