Skip to content

Commit 226e63d

Browse files
committed
Move server context implementation to grpc_impl namespace and typedef the ref to it
1 parent 26a2e81 commit 226e63d

26 files changed

+491
-431
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,5 @@ bm_*.json
144144
!.vscode/launch.json
145145
!.vscode/extensions.json
146146

147+
# Clion artifacts
148+
cmake-build-debug/

BUILD

+1
Original file line numberDiff line numberDiff line change
@@ -2185,6 +2185,7 @@ grpc_cc_library(
21852185
"include/grpcpp/impl/codegen/serialization_traits.h",
21862186
"include/grpcpp/impl/codegen/server_callback.h",
21872187
"include/grpcpp/impl/codegen/server_context.h",
2188+
"include/grpcpp/impl/codegen/server_context_impl.h",
21882189
"include/grpcpp/impl/codegen/server_interceptor.h",
21892190
"include/grpcpp/impl/codegen/server_interface.h",
21902191
"include/grpcpp/impl/codegen/service_type.h",

BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -1081,6 +1081,7 @@ config("grpc_config") {
10811081
"include/grpcpp/impl/codegen/serialization_traits.h",
10821082
"include/grpcpp/impl/codegen/server_callback.h",
10831083
"include/grpcpp/impl/codegen/server_context.h",
1084+
"include/grpcpp/impl/codegen/server_context_impl.h",
10841085
"include/grpcpp/impl/codegen/server_interceptor.h",
10851086
"include/grpcpp/impl/codegen/server_interface.h",
10861087
"include/grpcpp/impl/codegen/service_type.h",

CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -3334,6 +3334,7 @@ foreach(_hdr
33343334
include/grpcpp/impl/codegen/serialization_traits.h
33353335
include/grpcpp/impl/codegen/server_callback.h
33363336
include/grpcpp/impl/codegen/server_context.h
3337+
include/grpcpp/impl/codegen/server_context_impl.h
33373338
include/grpcpp/impl/codegen/server_interceptor.h
33383339
include/grpcpp/impl/codegen/server_interface.h
33393340
include/grpcpp/impl/codegen/service_type.h
@@ -3953,6 +3954,7 @@ foreach(_hdr
39533954
include/grpcpp/impl/codegen/serialization_traits.h
39543955
include/grpcpp/impl/codegen/server_callback.h
39553956
include/grpcpp/impl/codegen/server_context.h
3957+
include/grpcpp/impl/codegen/server_context_impl.h
39563958
include/grpcpp/impl/codegen/server_interceptor.h
39573959
include/grpcpp/impl/codegen/server_interface.h
39583960
include/grpcpp/impl/codegen/service_type.h
@@ -4388,6 +4390,7 @@ foreach(_hdr
43884390
include/grpcpp/impl/codegen/serialization_traits.h
43894391
include/grpcpp/impl/codegen/server_callback.h
43904392
include/grpcpp/impl/codegen/server_context.h
4393+
include/grpcpp/impl/codegen/server_context_impl.h
43914394
include/grpcpp/impl/codegen/server_interceptor.h
43924395
include/grpcpp/impl/codegen/server_interface.h
43934396
include/grpcpp/impl/codegen/service_type.h
@@ -4587,6 +4590,7 @@ foreach(_hdr
45874590
include/grpcpp/impl/codegen/serialization_traits.h
45884591
include/grpcpp/impl/codegen/server_callback.h
45894592
include/grpcpp/impl/codegen/server_context.h
4593+
include/grpcpp/impl/codegen/server_context_impl.h
45904594
include/grpcpp/impl/codegen/server_interceptor.h
45914595
include/grpcpp/impl/codegen/server_interface.h
45924596
include/grpcpp/impl/codegen/service_type.h
@@ -4946,6 +4950,7 @@ foreach(_hdr
49464950
include/grpcpp/impl/codegen/serialization_traits.h
49474951
include/grpcpp/impl/codegen/server_callback.h
49484952
include/grpcpp/impl/codegen/server_context.h
4953+
include/grpcpp/impl/codegen/server_context_impl.h
49494954
include/grpcpp/impl/codegen/server_interceptor.h
49504955
include/grpcpp/impl/codegen/server_interface.h
49514956
include/grpcpp/impl/codegen/service_type.h

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -5691,6 +5691,7 @@ PUBLIC_HEADERS_CXX += \
56915691
include/grpcpp/impl/codegen/serialization_traits.h \
56925692
include/grpcpp/impl/codegen/server_callback.h \
56935693
include/grpcpp/impl/codegen/server_context.h \
5694+
include/grpcpp/impl/codegen/server_context_impl.h \
56945695
include/grpcpp/impl/codegen/server_interceptor.h \
56955696
include/grpcpp/impl/codegen/server_interface.h \
56965697
include/grpcpp/impl/codegen/service_type.h \
@@ -6318,6 +6319,7 @@ PUBLIC_HEADERS_CXX += \
63186319
include/grpcpp/impl/codegen/serialization_traits.h \
63196320
include/grpcpp/impl/codegen/server_callback.h \
63206321
include/grpcpp/impl/codegen/server_context.h \
6322+
include/grpcpp/impl/codegen/server_context_impl.h \
63216323
include/grpcpp/impl/codegen/server_interceptor.h \
63226324
include/grpcpp/impl/codegen/server_interface.h \
63236325
include/grpcpp/impl/codegen/service_type.h \
@@ -6725,6 +6727,7 @@ PUBLIC_HEADERS_CXX += \
67256727
include/grpcpp/impl/codegen/serialization_traits.h \
67266728
include/grpcpp/impl/codegen/server_callback.h \
67276729
include/grpcpp/impl/codegen/server_context.h \
6730+
include/grpcpp/impl/codegen/server_context_impl.h \
67286731
include/grpcpp/impl/codegen/server_interceptor.h \
67296732
include/grpcpp/impl/codegen/server_interface.h \
67306733
include/grpcpp/impl/codegen/service_type.h \
@@ -6895,6 +6898,7 @@ PUBLIC_HEADERS_CXX += \
68956898
include/grpcpp/impl/codegen/serialization_traits.h \
68966899
include/grpcpp/impl/codegen/server_callback.h \
68976900
include/grpcpp/impl/codegen/server_context.h \
6901+
include/grpcpp/impl/codegen/server_context_impl.h \
68986902
include/grpcpp/impl/codegen/server_interceptor.h \
68996903
include/grpcpp/impl/codegen/server_interface.h \
69006904
include/grpcpp/impl/codegen/service_type.h \
@@ -7260,6 +7264,7 @@ PUBLIC_HEADERS_CXX += \
72607264
include/grpcpp/impl/codegen/serialization_traits.h \
72617265
include/grpcpp/impl/codegen/server_callback.h \
72627266
include/grpcpp/impl/codegen/server_context.h \
7267+
include/grpcpp/impl/codegen/server_context_impl.h \
72637268
include/grpcpp/impl/codegen/server_interceptor.h \
72647269
include/grpcpp/impl/codegen/server_interface.h \
72657270
include/grpcpp/impl/codegen/service_type.h \

build.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,7 @@ filegroups:
12811281
- include/grpcpp/impl/codegen/serialization_traits.h
12821282
- include/grpcpp/impl/codegen/server_callback.h
12831283
- include/grpcpp/impl/codegen/server_context.h
1284+
- include/grpcpp/impl/codegen/server_context_impl.h
12841285
- include/grpcpp/impl/codegen/server_interceptor.h
12851286
- include/grpcpp/impl/codegen/server_interface.h
12861287
- include/grpcpp/impl/codegen/service_type.h

gRPC-C++.podspec

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ Pod::Spec.new do |s|
182182
'include/grpcpp/impl/codegen/serialization_traits.h',
183183
'include/grpcpp/impl/codegen/server_callback.h',
184184
'include/grpcpp/impl/codegen/server_context.h',
185+
'include/grpcpp/impl/codegen/server_context_impl.h',
185186
'include/grpcpp/impl/codegen/server_interceptor.h',
186187
'include/grpcpp/impl/codegen/server_interface.h',
187188
'include/grpcpp/impl/codegen/service_type.h',

include/grpcpp/impl/codegen/client_context.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace grpc_impl {
6262
class CallCredentials;
6363
class Channel;
6464
class CompletionQueue;
65+
class ServerContext;
6566
} // namespace grpc_impl
6667
namespace grpc {
6768

@@ -99,7 +100,6 @@ template <class W, class R>
99100
class ClientAsyncReaderWriter;
100101
template <class R>
101102
class ClientAsyncResponseReader;
102-
class ServerContext;
103103

104104
/// Options for \a ClientContext::FromServerContext specifying which traits from
105105
/// the \a ServerContext to propagate (copy) from it into a new \a
@@ -192,12 +192,12 @@ class ClientContext {
192192
/// \return A newly constructed \a ClientContext instance based on \a
193193
/// server_context, with traits propagated (copied) according to \a options.
194194
static std::unique_ptr<ClientContext> FromServerContext(
195-
const ServerContext& server_context,
195+
const ::grpc_impl::ServerContext& server_context,
196196
PropagationOptions options = PropagationOptions());
197197

198198
/// Add the (\a meta_key, \a meta_value) pair to the metadata associated with
199199
/// a client call. These are made available at the server side by the \a
200-
/// grpc::ServerContext::client_metadata() method.
200+
/// grpc_impl::ServerContext::client_metadata() method.
201201
///
202202
/// \warning This method should only be called before invoking the rpc.
203203
///

include/grpcpp/impl/codegen/completion_queue_impl.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace grpc_impl {
4646
class Channel;
4747
class Server;
4848
class ServerBuilder;
49+
class ServerContext;
4950
} // namespace grpc_impl
5051
namespace grpc {
5152

@@ -66,7 +67,6 @@ class ServerReaderWriterBody;
6667

6768
class ChannelInterface;
6869
class ClientContext;
69-
class ServerContext;
7070
class ServerInterface;
7171

7272
namespace internal {
@@ -278,7 +278,7 @@ class CompletionQueue : private ::grpc::GrpcLibraryCodegen {
278278
template <::grpc::StatusCode code>
279279
friend class ::grpc::internal::ErrorMethodHandler;
280280
friend class ::grpc_impl::Server;
281-
friend class ::grpc::ServerContext;
281+
friend class ::grpc_impl::ServerContext;
282282
friend class ::grpc::ServerInterface;
283283
template <class InputMessage, class OutputMessage>
284284
friend class ::grpc::internal::BlockingUnaryCallImpl;

include/grpcpp/impl/codegen/rpc_service_method.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
#include <grpcpp/impl/codegen/rpc_method.h>
3232
#include <grpcpp/impl/codegen/status.h>
3333

34-
namespace grpc {
34+
namespace grpc_impl {
3535
class ServerContext;
36+
}
3637

38+
namespace grpc {
3739
namespace internal {
3840
/// Base class for running an RPC handler.
3941
class MethodHandler {
@@ -50,7 +52,7 @@ class MethodHandler {
5052
/// \param requester : used only by the callback API. It is a function
5153
/// called by the RPC Controller to request another RPC (and also
5254
/// to set up the state required to make that request possible)
53-
HandlerParameter(Call* c, ServerContext* context, void* req,
55+
HandlerParameter(Call* c, ::grpc_impl::ServerContext* context, void* req,
5456
Status req_status, void* handler_data,
5557
std::function<void()> requester)
5658
: call(c),
@@ -61,7 +63,7 @@ class MethodHandler {
6163
call_requester(std::move(requester)) {}
6264
~HandlerParameter() {}
6365
Call* call;
64-
ServerContext* server_context;
66+
::grpc_impl::ServerContext* server_context;
6567
void* request;
6668
Status status;
6769
void* internal_data;

include/grpcpp/impl/codegen/server_callback.h

+23-19
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <grpcpp/impl/codegen/config.h>
3030
#include <grpcpp/impl/codegen/core_codegen_interface.h>
3131
#include <grpcpp/impl/codegen/message_allocator.h>
32-
#include <grpcpp/impl/codegen/server_context.h>
32+
#include <grpcpp/impl/codegen/server_context_impl.h>
3333
#include <grpcpp/impl/codegen/server_interface.h>
3434
#include <grpcpp/impl/codegen/status.h>
3535

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

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

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

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

418419
/// The following notifications are exactly like ServerBidiReactor.
419420
virtual void OnSendInitialMetadataDone(bool ok) {}
@@ -437,7 +438,7 @@ class UnimplementedReadReactor
437438
: public experimental::ServerReadReactor<Request, Response> {
438439
public:
439440
void OnDone() override { delete this; }
440-
void OnStarted(ServerContext*, Response*) override {
441+
void OnStarted(::grpc_impl::ServerContext*, Response*) override {
441442
this->Finish(Status(StatusCode::UNIMPLEMENTED, ""));
442443
}
443444
};
@@ -447,7 +448,7 @@ class UnimplementedWriteReactor
447448
: public experimental::ServerWriteReactor<Request, Response> {
448449
public:
449450
void OnDone() override { delete this; }
450-
void OnStarted(ServerContext*, const Request*) override {
451+
void OnStarted(::grpc_impl::ServerContext*, const Request*) override {
451452
this->Finish(Status(StatusCode::UNIMPLEMENTED, ""));
452453
}
453454
};
@@ -457,7 +458,7 @@ class UnimplementedBidiReactor
457458
: public experimental::ServerBidiReactor<Request, Response> {
458459
public:
459460
void OnDone() override { delete this; }
460-
void OnStarted(ServerContext*) override {
461+
void OnStarted(::grpc_impl::ServerContext*) override {
461462
this->Finish(Status(StatusCode::UNIMPLEMENTED, ""));
462463
}
463464
};
@@ -466,7 +467,8 @@ template <class RequestType, class ResponseType>
466467
class CallbackUnaryHandler : public MethodHandler {
467468
public:
468469
CallbackUnaryHandler(
469-
std::function<void(ServerContext*, const RequestType*, ResponseType*,
470+
std::function<void(::grpc_impl::ServerContext*, const RequestType*,
471+
ResponseType*,
470472
experimental::ServerCallbackRpcController*)>
471473
func)
472474
: func_(func) {}
@@ -525,8 +527,8 @@ class CallbackUnaryHandler : public MethodHandler {
525527
}
526528

527529
private:
528-
std::function<void(ServerContext*, const RequestType*, ResponseType*,
529-
experimental::ServerCallbackRpcController*)>
530+
std::function<void(::grpc_impl::ServerContext*, const RequestType*,
531+
ResponseType*, experimental::ServerCallbackRpcController*)>
530532
func_;
531533
experimental::MessageAllocator<RequestType, ResponseType>* allocator_ =
532534
nullptr;
@@ -597,7 +599,7 @@ class CallbackUnaryHandler : public MethodHandler {
597599
friend class CallbackUnaryHandler<RequestType, ResponseType>;
598600

599601
ServerCallbackRpcControllerImpl(
600-
ServerContext* ctx, Call* call,
602+
::grpc_impl::ServerContext* ctx, Call* call,
601603
experimental::MessageHolder<RequestType, ResponseType>* allocator_state,
602604
std::function<void()> call_requester)
603605
: ctx_(ctx),
@@ -628,7 +630,7 @@ class CallbackUnaryHandler : public MethodHandler {
628630
finish_ops_;
629631
CallbackWithSuccessTag finish_tag_;
630632

631-
ServerContext* ctx_;
633+
::grpc_impl::ServerContext* ctx_;
632634
Call call_;
633635
experimental::MessageHolder<RequestType, ResponseType>* const
634636
allocator_state_;
@@ -732,7 +734,8 @@ class CallbackClientStreamingHandler : public MethodHandler {
732734
friend class CallbackClientStreamingHandler<RequestType, ResponseType>;
733735

734736
ServerCallbackReaderImpl(
735-
ServerContext* ctx, Call* call, std::function<void()> call_requester,
737+
::grpc_impl::ServerContext* ctx, Call* call,
738+
std::function<void()> call_requester,
736739
experimental::ServerReadReactor<RequestType, ResponseType>* reactor)
737740
: ctx_(ctx),
738741
call_(*call),
@@ -772,7 +775,7 @@ class CallbackClientStreamingHandler : public MethodHandler {
772775
CallOpSet<CallOpRecvMessage<RequestType>> read_ops_;
773776
CallbackWithSuccessTag read_tag_;
774777

775-
ServerContext* ctx_;
778+
::grpc_impl::ServerContext* ctx_;
776779
Call call_;
777780
ResponseType resp_;
778781
std::function<void()> call_requester_;
@@ -909,7 +912,7 @@ class CallbackServerStreamingHandler : public MethodHandler {
909912
friend class CallbackServerStreamingHandler<RequestType, ResponseType>;
910913

911914
ServerCallbackWriterImpl(
912-
ServerContext* ctx, Call* call, const RequestType* req,
915+
::grpc_impl::ServerContext* ctx, Call* call, const RequestType* req,
913916
std::function<void()> call_requester,
914917
experimental::ServerWriteReactor<RequestType, ResponseType>* reactor)
915918
: ctx_(ctx),
@@ -950,7 +953,7 @@ class CallbackServerStreamingHandler : public MethodHandler {
950953
CallOpSet<CallOpSendInitialMetadata, CallOpSendMessage> write_ops_;
951954
CallbackWithSuccessTag write_tag_;
952955

953-
ServerContext* ctx_;
956+
::grpc_impl::ServerContext* ctx_;
954957
Call call_;
955958
const RequestType* req_;
956959
std::function<void()> call_requester_;
@@ -1078,7 +1081,8 @@ class CallbackBidiHandler : public MethodHandler {
10781081
friend class CallbackBidiHandler<RequestType, ResponseType>;
10791082

10801083
ServerCallbackReaderWriterImpl(
1081-
ServerContext* ctx, Call* call, std::function<void()> call_requester,
1084+
::grpc_impl::ServerContext* ctx, Call* call,
1085+
std::function<void()> call_requester,
10821086
experimental::ServerBidiReactor<RequestType, ResponseType>* reactor)
10831087
: ctx_(ctx),
10841088
call_(*call),
@@ -1124,7 +1128,7 @@ class CallbackBidiHandler : public MethodHandler {
11241128
CallOpSet<CallOpRecvMessage<RequestType>> read_ops_;
11251129
CallbackWithSuccessTag read_tag_;
11261130

1127-
ServerContext* ctx_;
1131+
::grpc_impl::ServerContext* ctx_;
11281132
Call call_;
11291133
std::function<void()> call_requester_;
11301134
experimental::ServerBidiReactor<RequestType, ResponseType>* reactor_;

0 commit comments

Comments
 (0)