GRPC C++  1.82.0
server_context.h
Go to the documentation of this file.
1 //
2 //
3 // Copyright 2015 gRPC authors.
4 //
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17 //
18 
19 #ifndef GRPCPP_SERVER_CONTEXT_H
20 #define GRPCPP_SERVER_CONTEXT_H
21 
22 #include <grpc/grpc.h>
23 #include <grpc/impl/call.h>
26 #include <grpcpp/impl/call.h>
33 #include <grpcpp/impl/sync.h>
36 #include <grpcpp/support/config.h>
40 #include <grpcpp/support/status.h>
42 #include <grpcpp/support/time.h>
43 
44 #include <atomic>
45 #include <cassert>
46 #include <cstdint>
47 #include <map>
48 #include <memory>
49 #include <type_traits>
50 #include <vector>
51 
52 struct grpc_metadata;
53 struct grpc_call;
54 struct census_context;
55 
56 namespace grpc {
57 template <class W, class R>
59 template <class W>
61 template <class W>
63 template <class W, class R>
65 template <class R>
66 class ServerReader;
67 template <class W>
68 class ServerWriter;
69 
70 namespace internal {
71 template <class ServiceType, class RequestType, class ResponseType>
73 template <class RequestType, class ResponseType>
75 template <class RequestType, class ResponseType>
77 template <class RequestType, class ResponseType>
79 template <class RequestType, class ResponseType>
81 template <class ServiceType, class RequestType, class ResponseType>
83 template <class ResponseType>
85  ResponseType*, Status&);
86 template <class ServiceType, class RequestType, class ResponseType,
87  class BaseRequestType, class BaseResponseType>
88 class RpcMethodHandler;
89 template <class Base>
91 template <class W, class R>
93 template <class ServiceType, class RequestType, class ResponseType>
95 class ServerReactor;
96 template <class Streamer, bool WriteNeeded>
98 template <grpc::StatusCode code>
99 class ErrorMethodHandler;
100 } // namespace internal
101 
102 class ClientContext;
103 class CompletionQueue;
105 class Server;
106 class ServerInterface;
107 class ContextAllocator;
109 
110 namespace internal {
111 class Call;
112 
113 void ServerContextSetSessionContext(grpc_call* call, uint16_t id, void* ptr);
114 void* ServerContextGetSessionContext(grpc_call* call, uint16_t id);
115 uint16_t ServerContextRegisterSessionContext(void (*destroy)(void*));
116 
117 template <typename T>
119  static uint16_t id() {
120  static const uint16_t id =
121  ServerContextRegisterSessionContext([](void* element) {
122  delete static_cast<std::shared_ptr<T>*>(element);
123  });
124  return id;
125  }
126 
127  static void* Wrap(std::shared_ptr<T> context) {
128  return new std::shared_ptr<T>(std::move(context));
129  }
130 
131  static std::shared_ptr<T> Unwrap(void* ptr) {
132  return ptr != nullptr ? *static_cast<std::shared_ptr<T>*>(ptr) : nullptr;
133  }
134 };
135 } // namespace internal
136 
137 namespace testing {
138 class InteropServerContextInspector;
139 class ServerContextTestSpouse;
140 class DefaultReactorTestPeer;
141 } // namespace testing
142 
143 class ServerContextBase;
144 
145 namespace experimental {
166 template <typename T>
167 void SetSessionContext(ServerContextBase* context,
168  std::shared_ptr<T> session_context);
169 
181 template <typename T>
182 std::shared_ptr<T> GetSessionContext(const ServerContextBase* context);
183 
184 class CallMetricRecorder;
185 class ServerMetricRecorder;
186 namespace internal {
187 template <class RequestType>
188 class CallbackSessionHandler;
189 } // namespace internal
190 } // namespace experimental
191 
194  public:
195  virtual ~ServerContextBase();
196 
198  std::chrono::system_clock::time_point deadline() const {
199  return grpc::Timespec2Timepoint(deadline_);
200  }
201 
203  gpr_timespec raw_deadline() const { return deadline_; }
204 
228  void AddInitialMetadata(const std::string& key, const std::string& value);
229 
253  void AddTrailingMetadata(const std::string& key, const std::string& value);
254 
266  bool IsCancelled() const;
267 
288  void TryCancel() const;
289 
299  const std::multimap<grpc::string_ref, grpc::string_ref>& client_metadata()
300  const {
301  return *client_metadata_.map();
302  }
303 
306  return compression_level_;
307  }
308 
313  compression_level_set_ = true;
314  compression_level_ = level;
315  }
316 
320  bool compression_level_set() const { return compression_level_set_; }
321 
327  return compression_algorithm_;
328  }
333 
335  void SetLoadReportingCosts(const std::vector<std::string>& cost_data);
336 
340  std::shared_ptr<const grpc::AuthContext> auth_context() const {
341  if (auth_context_ == nullptr) {
342  auth_context_ = grpc::CreateAuthContext(call_.call);
343  }
344  return auth_context_;
345  }
346 
351  std::string peer() const;
352 
354  const struct census_context* census_context() const;
355 
358  grpc_call* c_call() { return call_.call; }
359 
366  return call_metric_recorder_;
367  }
368 
370  return memory_allocator_;
371  }
372 
376 
377  protected:
383  void AsyncNotifyWhenDone(void* tag) {
384  has_notify_when_done_tag_ = true;
385  async_notify_when_done_tag_ = tag;
386  }
387 
391  RpcAllocatorState* GetRpcAllocatorState() { return message_allocator_state_; }
392 
408  // Short-circuit the case where a default reactor was already set up by
409  // the TestPeer.
410  if (test_unary_ != nullptr) {
411  return reinterpret_cast<Reactor*>(&default_reactor_);
412  }
413  new (&default_reactor_) Reactor;
414 #ifndef NDEBUG
415  bool old = false;
416  assert(default_reactor_used_.compare_exchange_strong(
417  old, true, std::memory_order_relaxed));
418 #else
419  default_reactor_used_.store(true, std::memory_order_relaxed);
420 #endif
421  return reinterpret_cast<Reactor*>(&default_reactor_);
422  }
423 
425  // Lock prevents the session from transitioning to the lock-free read phase
426  // while a concurrent call to SetSessionContext is currently executing.
427  grpc::internal::MutexLock lock(&metadata_mu_);
428  // Release-store synchronizes with the acquire-loads in
429  // Set/GetSessionContext to guarantee that all context writes made before
430  // initial metadata is sent are fully visible to subsequent read operations.
431  sent_initial_metadata_.store(true, std::memory_order_release);
432  }
433 
437 
439  context_allocator_ = context_allocator;
440  }
441 
442  ContextAllocator* context_allocator() const { return context_allocator_; }
443 
444  private:
448  friend class grpc::ServerInterface;
449  friend class grpc::Server;
450  template <class W, class R>
452  template <class W>
454  template <class W>
456  template <class W, class R>
458  template <class R>
459  friend class grpc::ServerReader;
460  template <class W>
461  friend class grpc::ServerWriter;
462  template <class W, class R>
464  template <class ResponseType>
466  const internal::MethodHandler::HandlerParameter& param, ResponseType* rsp,
467  Status& status);
468  template <class ServiceType, class RequestType, class ResponseType,
469  class BaseRequestType, class BaseResponseType>
471  template <class ServiceType, class RequestType, class ResponseType>
473  template <class ServiceType, class RequestType, class ResponseType>
475  template <class Streamer, bool WriteNeeded>
477  template <class RequestType, class ResponseType>
479  template <class RequestType, class ResponseType>
481  template <class RequestType, class ResponseType>
483  template <class RequestType, class ResponseType>
485  template <class RequestType>
487  template <grpc::StatusCode code>
489  template <class Base>
491  friend class grpc::ClientContext;
494 
495  template <typename T>
497  ServerContextBase* context, std::shared_ptr<T> session_context);
498  template <typename T>
499  friend std::shared_ptr<T> experimental::GetSessionContext(
500  const ServerContextBase* context);
501 
502  template <typename T>
503  void SetSessionContext(std::shared_ptr<T> context) {
504  if (!sent_initial_metadata_.load(std::memory_order_acquire)) {
505  grpc::internal::MutexLock lock(&metadata_mu_);
506  if (!sent_initial_metadata_.load(std::memory_order_acquire)) {
509  internal::SessionContextType<T>::Wrap(std::move(context)));
510  }
511  }
512  }
513 
514  template <typename T>
515  std::shared_ptr<T> GetSessionContext() const {
516  if (sent_initial_metadata_.load(std::memory_order_acquire)) {
519  call_.call, internal::SessionContextType<T>::id()));
520  } else {
521  grpc::internal::MutexLock lock(&metadata_mu_);
524  call_.call, internal::SessionContextType<T>::id()));
525  }
526  }
527 
530  ServerContextBase& operator=(const ServerContextBase&);
531 
532  class CompletionOp;
533 
534  void BeginCompletionOp(
535  grpc::internal::Call* call, std::function<void(bool)> callback,
536  grpc::internal::ServerCallbackCall* callback_controller);
538  grpc::internal::CompletionQueueTag* GetCompletionOpTag();
539 
540  void set_call(
541  grpc_call* call, bool call_metric_recording_enabled,
542  experimental::ServerMetricRecorder* server_metric_recorder,
544  call_.call = call;
545  if (call_metric_recording_enabled) {
546  CreateCallMetricRecorder(server_metric_recorder);
547  }
548  memory_allocator_ = memory_allocator;
549  }
550 
551  void BindDeadlineAndMetadata(gpr_timespec deadline, grpc_metadata_array* arr);
552 
553  uint32_t initial_metadata_flags() const { return 0; }
554 
555  grpc::experimental::ServerRpcInfo* set_server_rpc_info(
556  const char* method, grpc::internal::RpcMethod::RpcType type,
557  const std::vector<std::unique_ptr<
559  if (!creators.empty()) {
560  rpc_info_ = new grpc::experimental::ServerRpcInfo(this, method, type);
561  rpc_info_->RegisterInterceptors(creators);
562  }
563  return rpc_info_;
564  }
565 
566  void set_message_allocator_state(RpcAllocatorState* allocator_state) {
567  message_allocator_state_ = allocator_state;
568  }
569 
570  void MaybeMarkCancelledOnRead() {
571  if (grpc_call_failed_before_recv_message(call_.call)) {
572  marked_cancelled_.store(true, std::memory_order_release);
573  }
574  }
575 
576  // This should be called only once and only when call metric recording is
577  // enabled.
578  void CreateCallMetricRecorder(
579  experimental::ServerMetricRecorder* server_metric_recorder = nullptr);
580 
581  struct CallWrapper {
582  ~CallWrapper();
583 
584  grpc_call* call = nullptr;
585  };
586 
587  // NOTE: call_ must be the first data member of this object so that its
588  // destructor is the last to be called, since its destructor may unref
589  // the underlying core call which holds the arena that may be used to
590  // hold this object.
591  CallWrapper call_;
592 
593  CompletionOp* completion_op_ = nullptr;
594  bool has_notify_when_done_tag_ = false;
595  void* async_notify_when_done_tag_ = nullptr;
597 
598  gpr_timespec deadline_;
599  grpc::CompletionQueue* cq_ = nullptr;
600  std::atomic<bool> sent_initial_metadata_{false};
601  mutable grpc::internal::Mutex metadata_mu_;
602  mutable std::shared_ptr<const grpc::AuthContext> auth_context_;
603  mutable grpc::internal::MetadataMap client_metadata_;
604  std::multimap<std::string, std::string> initial_metadata_;
605  std::multimap<std::string, std::string> trailing_metadata_;
606 
607  bool compression_level_set_ = false;
608  grpc_compression_level compression_level_;
609  grpc_compression_algorithm compression_algorithm_;
610 
613  pending_ops_;
614  bool has_pending_ops_ = false;
615 
616  grpc::experimental::ServerRpcInfo* rpc_info_ = nullptr;
617  RpcAllocatorState* message_allocator_state_ = nullptr;
618  ContextAllocator* context_allocator_ = nullptr;
619  experimental::CallMetricRecorder* call_metric_recorder_ = nullptr;
620  grpc_event_engine::experimental::MemoryAllocator* memory_allocator_ = nullptr;
621 
622  class Reactor : public grpc::ServerUnaryReactor {
623  public:
624  void OnCancel() override {}
625  void OnDone() override {}
626  // Override InternalInlineable for this class since its reactions are
627  // trivial and thus do not need to be run from the EventEngine (potentially
628  // triggering a thread hop). This should only be used by internal reactors
629  // (thus the name) and not by user application code.
630  bool InternalInlineable() override { return true; }
631  };
632 
633  void SetupTestDefaultReactor(std::function<void(grpc::Status)> func) {
634  // NOLINTNEXTLINE(modernize-make-unique)
635  test_unary_.reset(new TestServerCallbackUnary(this, std::move(func)));
636  }
637  bool test_status_set() const {
638  return (test_unary_ != nullptr) && test_unary_->status_set();
639  }
640  grpc::Status test_status() const { return test_unary_->status(); }
641 
642  class TestServerCallbackUnary : public grpc::ServerCallbackUnary {
643  public:
644  TestServerCallbackUnary(ServerContextBase* ctx,
645  std::function<void(grpc::Status)> func)
646  : reactor_(ctx->DefaultReactor()),
647  func_(std::move(func)),
648  call_(ctx->c_call()) {
649  this->BindReactor(reactor_);
650  }
651  void Finish(grpc::Status s) override {
652  status_ = s;
653  func_(std::move(s));
654  status_set_.store(true, std::memory_order_release);
655  }
656  void SendInitialMetadata() override {}
657 
658  bool status_set() const {
659  return status_set_.load(std::memory_order_acquire);
660  }
661  grpc::Status status() const { return status_; }
662 
663  private:
664  void CallOnDone() override {}
665 
666  grpc_call* call() override { return call_; }
667 
668  grpc::internal::ServerReactor* reactor() override { return reactor_; }
669 
670  grpc::ServerUnaryReactor* const reactor_;
671  std::atomic_bool status_set_{false};
672  grpc::Status status_;
673  const std::function<void(grpc::Status s)> func_;
674  grpc_call* call_;
675  };
676 
677  alignas(Reactor) char default_reactor_[sizeof(Reactor)];
678  std::atomic_bool default_reactor_used_{false};
679 
680  std::atomic_bool marked_cancelled_{false};
681 
682  std::unique_ptr<TestServerCallbackUnary> test_unary_;
683 };
684 
702  public:
703  ServerContext() {} // for async calls
704 
722 
723  // Sync/CQ-based Async ServerContext only
725 
726  private:
727  // Constructor for internal use by server only
728  friend class grpc::Server;
730  : ServerContextBase(deadline, arr) {}
731 
732  // CallbackServerContext only
735 
737  ServerContext(const ServerContext&) = delete;
738  ServerContext& operator=(const ServerContext&) = delete;
739 };
740 
742  public:
746 
766 
767  // CallbackServerContext only
770 
771  private:
772  // Sync/CQ-based Async ServerContext only
774 
777  CallbackServerContext& operator=(const CallbackServerContext&) = delete;
778 };
779 
786  public:
787  virtual ~ContextAllocator() {}
788 
789  virtual CallbackServerContext* NewCallbackServerContext() { return nullptr; }
790 
792  return nullptr;
793  }
794 
795  virtual void Release(CallbackServerContext*) {}
796 
798 };
799 
800 namespace experimental {
801 
802 template <typename T>
804  std::shared_ptr<T> session_context) {
805  context->SetSessionContext(std::move(session_context));
806 }
807 
808 template <typename T>
809 inline std::shared_ptr<T> GetSessionContext(const ServerContextBase* context) {
810  return context->GetSessionContext<T>();
811 }
812 
813 } // namespace experimental
814 
815 } // namespace grpc
816 
817 static_assert(
818  std::is_base_of<grpc::ServerContextBase, grpc::ServerContext>::value,
819  "improper base class");
820 static_assert(std::is_base_of<grpc::ServerContextBase,
822  "improper base class");
823 static_assert(sizeof(grpc::ServerContextBase) == sizeof(grpc::ServerContext),
824  "wrong size");
825 static_assert(sizeof(grpc::ServerContextBase) ==
827  "wrong size");
828 
829 #endif // GRPCPP_SERVER_CONTEXT_H
grpc::internal::CallbackWithSuccessTag
CallbackWithSuccessTag can be reused multiple times, and will be used in this fashion for streaming o...
Definition: callback_common.h:153
grpc::string_ref
This class is a non owning reference to a string.
Definition: string_ref.h:40
census_context
struct census_context census_context
A Census Context is a handle used by Census to represent the current tracing and stats collection inf...
Definition: census.h:33
grpc::internal::ServerContextRegisterSessionContext
uint16_t ServerContextRegisterSessionContext(void(*destroy)(void *))
grpc::ServerContextBase::set_compression_algorithm
void set_compression_algorithm(grpc_compression_algorithm algorithm)
Set algorithm to be the compression algorithm used for the server call.
time.h
grpc::ServerContextBase::SetLoadReportingCosts
void SetLoadReportingCosts(const std::vector< std::string > &cost_data)
Set the serialized load reporting costs in cost_data for the call.
message_allocator.h
grpc::ContextAllocator::NewGenericCallbackServerContext
virtual GenericCallbackServerContext * NewGenericCallbackServerContext()
Definition: server_context.h:791
grpc::ServerContext
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:701
grpc::Server
Represents a gRPC server.
Definition: server.h:58
grpc::ServerContextBase::census_context
const struct census_context * census_context() const
Get the census context associated with this server call.
grpc
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
grpc::internal::CallOpSet
Primary implementation of CallOpSetInterface.
Definition: completion_queue.h:97
grpc::ServerContextBase::IsCancelled
bool IsCancelled() const
Return whether this RPC failed before the server could provide its status back to the client.
grpc::CallbackServerContext
Definition: server_context.h:741
grpc::ServerContextBase::set_context_allocator
void set_context_allocator(ContextAllocator *context_allocator)
Definition: server_context.h:438
grpc::internal::CallOpSendMessage
Definition: call_op_set.h:287
grpc::RpcAllocatorState
Definition: message_allocator.h:26
grpc_call_failed_before_recv_message
GRPCAPI int grpc_call_failed_before_recv_message(const grpc_call *c)
grpc::ServerAsyncWriter
Async server-side API for doing server streaming RPCs, where the outgoing message stream from the ser...
Definition: server_context.h:60
grpc::internal::ErrorMethodHandler
General method handler class for errors that prevent real method use e.g., handle unknown method by r...
Definition: completion_queue.h:81
grpc::internal::MethodHandler::HandlerParameter
Definition: rpc_service_method.h:43
grpc_metadata_array
Definition: grpc_types.h:251
grpc::internal::RpcMethodHandler
A wrapper class of an application provided rpc method handler.
Definition: completion_queue.h:73
grpc::ServerWriter
Synchronous (blocking) server-side API for doing for doing a server-streaming RPCs,...
Definition: completion_queue.h:62
grpc_compression_algorithm
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level)
Definition: compression_types.h:61
grpc::ServerContextBase::DefaultReactor
grpc::ServerUnaryReactor * DefaultReactor()
Get a library-owned default unary reactor for use in minimal reaction cases.
Definition: server_context.h:407
grpc::internal::Call
Straightforward wrapping of the C call object.
Definition: call.h:34
grpc::ServerContextBase
Base class of ServerContext.
Definition: server_context.h:193
rpc_service_method.h
grpc::ServerContextBase::memory_allocator
grpc_event_engine::experimental::MemoryAllocator * memory_allocator()
Definition: server_context.h:369
grpc::ServerContextBase::context_allocator
ContextAllocator * context_allocator() const
Definition: server_context.h:442
status.h
grpc::ServerCallbackUnary::BindReactor
void BindReactor(Reactor *reactor)
Definition: server_callback.h:234
grpc::internal::CallOpSendInitialMetadata
Definition: call_op_set.h:217
grpc::ServerContextBase::ServerContextBase
ServerContextBase()
Constructors for use by derived classes.
completion_queue_tag.h
grpc::internal::MetadataMap
Definition: metadata_map.h:33
metadata_map.h
grpc::internal::ServerReaderWriterBody
Definition: completion_queue.h:65
grpc::internal::SessionContextType::id
static uint16_t id()
Definition: server_context.h:119
grpc::ServerContextBase::DefaultReactorTestPeer
friend class grpc::testing::DefaultReactorTestPeer
Definition: server_context.h:447
grpc::ServerContextBase::ServerContextTestSpouse
friend class grpc::testing::ServerContextTestSpouse
Definition: server_context.h:446
grpc::internal::MetadataMap::map
std::multimap< grpc::string_ref, grpc::string_ref > * map()
Definition: metadata_map.h:66
grpc::Status
Did it work? If it didn't, why?
Definition: status.h:34
grpc_metadata
A single metadata element.
Definition: grpc_types.h:209
grpc::ContextAllocator::Release
virtual void Release(CallbackServerContext *)
Definition: server_context.h:795
grpc::experimental::CallMetricRecorder
Records call metrics for the purpose of load balancing.
Definition: call_metric_recorder.h:36
grpc::ServerContextBase::ExperimentalGetCallMetricRecorder
experimental::CallMetricRecorder * ExperimentalGetCallMetricRecorder()
Get the CallMetricRecorder object for the current RPC.
Definition: server_context.h:365
grpc::internal::ServerCallbackCall
The base class of ServerCallbackUnary etc.
Definition: server_callback.h:95
grpc::CreateAuthContext
std::shared_ptr< const AuthContext > CreateAuthContext(grpc_call *call)
TODO(ctiller): not sure we want to make this a permanent thing.
grpc::ServerReader
Synchronous (blocking) server-side API for doing client-streaming RPCs, where the incoming message st...
Definition: completion_queue.h:60
grpc::ServerContextBase::deadline
std::chrono::system_clock::time_point deadline() const
Return the deadline for the server call.
Definition: server_context.h:198
grpc::ServerContextBase::raw_deadline
gpr_timespec raw_deadline() const
Return a gpr_timespec representation of the server call's deadline.
Definition: server_context.h:203
callback_common.h
grpc::internal::SessionContextType::Wrap
static void * Wrap(std::shared_ptr< T > context)
Definition: server_context.h:127
grpc::ClientContext
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:203
grpc::ServerContextBase::GetRpcAllocatorState
RpcAllocatorState * GetRpcAllocatorState()
NOTE: This is an API for advanced users who need custom allocators.
Definition: server_context.h:391
grpc::ServerContextBase::AddInitialMetadata
void AddInitialMetadata(const std::string &key, const std::string &value)
Add the (key, value) pair to the initial metadata associated with a server call.
grpc.h
grpc_call
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:68
grpc::internal::CallbackUnaryHandler
Definition: server_callback_handlers.h:38
grpc::ServerContextBase::auth_context
std::shared_ptr< const grpc::AuthContext > auth_context() const
Return the authentication context for this server call.
Definition: server_context.h:340
grpc::internal::CallbackServerStreamingHandler
Definition: server_callback_handlers.h:452
grpc::ServerContextBase::compression_level_set
bool compression_level_set() const
Return a bool indicating whether the compression level for this call has been set (either implicitly ...
Definition: server_context.h:320
grpc::ContextAllocator::NewCallbackServerContext
virtual CallbackServerContext * NewCallbackServerContext()
Definition: server_context.h:789
grpc::internal::RpcMethod::RpcType
RpcType
Definition: rpc_method.h:31
grpc::CallbackServerContext::CallbackServerContext
CallbackServerContext()
Public constructors are for direct use only by mocking tests.
Definition: server_context.h:745
grpc::GenericServerContext
Definition: async_generic_service.h:37
grpc::ServerContextBase::AddTrailingMetadata
void AddTrailingMetadata(const std::string &key, const std::string &value)
Add the (key, value) pair to the initial metadata associated with a server call.
grpc::experimental::ServerRpcInfo
ServerRpcInfo represents the state of a particular RPC as it appears to an interceptor.
Definition: server_interceptor.h:58
grpc::internal::FinishOnlyReactor
Definition: server_context.h:90
server_interceptor.h
grpc::internal::CompletionQueueTag
An interface allowing implementors to process and filter event tags.
Definition: completion_queue_tag.h:26
grpc::internal::SessionContextType
Definition: server_context.h:118
compression_types.h
grpc::ServerContextBase::client_metadata
const std::multimap< grpc::string_ref, grpc::string_ref > & client_metadata() const
Return a collection of initial metadata key-value pairs sent from the client.
Definition: server_context.h:299
server_callback.h
grpc::experimental::internal::CallbackSessionHandler
Definition: server_callback_handlers.h:912
grpc::experimental::ServerInterceptorFactoryInterface
Definition: server_interceptor.h:45
grpc::ServerContextBase::~ServerContextBase
virtual ~ServerContextBase()
grpc::internal::ServerStreamingHandler
A wrapper class of an application provided server streaming handler.
Definition: completion_queue.h:77
grpc::ServerAsyncResponseWriter
Async server-side API for handling unary calls, where the single response message sent to the client ...
Definition: server_context.h:62
grpc::internal::CallbackBidiHandler
Definition: server_callback_handlers.h:683
grpc::internal::MutexLock
Definition: sync.h:80
grpc::ContextAllocator
A CallbackServerContext allows users to use the contents of the CallbackServerContext or GenericCallb...
Definition: server_context.h:785
grpc::internal::ClientStreamingHandler
A wrapper class of an application provided client streaming handler.
Definition: completion_queue.h:75
grpc::ServerContextBase::AsyncNotifyWhenDone
void AsyncNotifyWhenDone(void *tag)
Async only.
Definition: server_context.h:383
grpc::internal::TemplatedBidiStreamingHandler
A wrapper class of an application provided bidi-streaming handler.
Definition: completion_queue.h:79
config.h
call.h
grpc::internal::BidiStreamingHandler
Definition: server_context.h:72
grpc::experimental::SetSessionContext
void SetSessionContext(ServerContextBase *context, std::shared_ptr< T > session_context)
Set the session context.
Definition: server_context.h:803
grpc::experimental::GetSessionContext
std::shared_ptr< T > GetSessionContext(const ServerContextBase *context)
Get the session context.
Definition: server_context.h:809
grpc_compression_level
grpc_compression_level
Compression levels allow a party with knowledge of its peer's accepted encodings to request compressi...
Definition: compression_types.h:73
call_op_set.h
std
Definition: async_unary_call.h:410
call.h
grpc::ServerContextBase::InteropServerContextInspector
friend class grpc::testing::InteropServerContextInspector
Definition: server_context.h:445
grpc::GenericCallbackServerContext
Definition: callback_generic_service.h:36
create_auth_context.h
grpc::ServerContextBase::peer
std::string peer() const
Return the peer uri in a string.
grpc::internal::ServerReactor
Definition: server_callback.h:71
grpc::CompletionQueue
A thin wrapper around grpc_completion_queue (see src/core/lib/surface/completion_queue....
Definition: completion_queue.h:104
grpc::ServerContextBase::ExperimentalGetAuthority
grpc::string_ref ExperimentalGetAuthority() const
EXPERIMENTAL API Returns the call's authority.
grpc::ServerContextBase::MarkInitialMetadataSent
void MarkInitialMetadataSent()
Definition: server_context.h:424
grpc::internal::CallbackClientStreamingHandler
Definition: server_callback_handlers.h:258
grpc_event_engine::experimental::MemoryAllocator
Definition: memory_allocator.h:33
grpc::ServerContextBase::TryCancel
void TryCancel() const
Cancel the Call from the server.
grpc::internal::SessionContextType::Unwrap
static std::shared_ptr< T > Unwrap(void *ptr)
Definition: server_context.h:131
grpc::ContextAllocator::~ContextAllocator
virtual ~ContextAllocator()
Definition: server_context.h:787
grpc::ServerAsyncReader
Async server-side API for doing client-streaming RPCs, where the incoming message stream from the cli...
Definition: server_context.h:58
grpc::internal::Mutex
Definition: sync.h:57
grpc::ServerAsyncReaderWriter
Async server-side API for doing bidirectional streaming RPCs, where the incoming message stream comin...
Definition: server_context.h:64
grpc::ServerInterface
Definition: server_interface.h:59
grpc::ServerContext::ServerContext
ServerContext()
Definition: server_context.h:703
gpr_timespec
Analogous to struct timespec.
Definition: time.h:47
grpc::internal::UnaryRunHandlerHelper
void UnaryRunHandlerHelper(const grpc::internal::MethodHandler::HandlerParameter &, ResponseType *, grpc::Status &)
A helper function with reduced templating to do the common work needed to actually send the server re...
Definition: method_handler.h:59
grpc::ServerCallbackUnary
Definition: server_callback.h:224
grpc::internal::ServerContextGetSessionContext
void * ServerContextGetSessionContext(grpc_call *call, uint16_t id)
grpc::ServerUnaryReactor
Definition: server_callback.h:749
auth_context.h
sync.h
grpc::ServerContextBase::compression_algorithm
grpc_compression_algorithm compression_algorithm() const
Return the compression algorithm the server call will request be used.
Definition: server_context.h:326
grpc::ServerContextBase::c_call
grpc_call * c_call()
Should be used for framework-level extensions only.
Definition: server_context.h:358
grpc::Timespec2Timepoint
std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t)
grpc::ContextAllocator::Release
virtual void Release(GenericCallbackServerContext *)
Definition: server_context.h:797
string_ref.h
grpc::ServerContextBase::set_compression_level
void set_compression_level(grpc_compression_level level)
Set level to be the compression level used for the server call.
Definition: server_context.h:312
metadata_map.h
port_platform.h
grpc::internal::ServerContextSetSessionContext
void ServerContextSetSessionContext(grpc_call *call, uint16_t id, void *ptr)
grpc::ServerContextBase::compression_level
grpc_compression_level compression_level() const
Return the compression algorithm to be used by the server call.
Definition: server_context.h:305