Go to the documentation of this file.
34 #ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H
35 #define GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H
63 class ServerContextBase;
64 class CallbackServerContext;
67 template <
class InputMessage,
class OutputMessage>
68 class CallbackUnaryCallImpl;
69 template <
class Request,
class Response>
70 class ClientCallbackReaderWriterImpl;
71 template <
class Response>
72 class ClientCallbackReaderImpl;
73 template <
class Request>
74 class ClientCallbackWriterImpl;
75 class ClientCallbackUnaryImpl;
76 class ClientContextAccessor;
77 class ClientAsyncResponseReaderHelper;
84 template <
class W,
class R>
85 class ClientReaderWriter;
90 template <
class W,
class R>
96 class InteropClientContextInspector;
97 class ClientContextTestPeer;
102 template <
class InputMessage,
class OutputMessage>
103 class BlockingUnaryCallImpl;
104 class CallOpClientRecvStatus;
105 class CallOpRecvInitialMetadata;
106 class ServerContextImpl;
107 template <
class InputMessage,
class OutputMessage>
108 class CallbackUnaryCallImpl;
109 template <
class Request,
class Response>
110 class ClientCallbackReaderWriterImpl;
111 template <
class Response>
112 class ClientCallbackReaderImpl;
113 template <
class Request>
114 class ClientCallbackWriterImpl;
115 class ClientCallbackUnaryImpl;
116 class ClientContextAccessor;
119 class CallCredentials;
121 class ChannelInterface;
122 class CompletionQueue;
239 void AddMetadata(
const std::string& meta_key,
const std::string& meta_value);
249 const std::multimap<grpc::string_ref, grpc::string_ref>&
252 return *recv_initial_metadata_.
map();
261 const std::multimap<grpc::string_ref, grpc::string_ref>&
264 return *trailing_metadata_.
map();
273 template <
typename T>
286 wait_for_ready_ = wait_for_ready;
287 wait_for_ready_explicitly_set_ =
true;
294 std::chrono::system_clock::time_point
deadline()
const {
303 void set_authority(
const std::string& authority) { authority_ = authority; }
310 if (auth_context_ ==
nullptr) {
313 return auth_context_;
326 void set_credentials(
const std::shared_ptr<grpc::CallCredentials>& creds);
333 std::shared_ptr<grpc::CallCredentials>
credentials() {
return creds_; }
339 return compression_algorithm_;
358 initial_metadata_corked_ = corked;
369 std::string
peer()
const;
379 return census_context_;
430 template <
class W,
class R>
436 template <
class W,
class R>
441 template <
class InputMessage,
class OutputMessage>
443 template <
class InputMessage,
class OutputMessage>
445 template <
class Request,
class Response>
447 template <
class Response>
449 template <
class Request>
459 grpc_call* call()
const {
return call_; }
460 void set_call(
grpc_call* call,
const std::shared_ptr<grpc::Channel>& channel);
463 const char* method,
const char* suffix_for_stats,
465 const std::vector<std::unique_ptr<
467 size_t interceptor_pos) {
469 suffix_for_stats, channel);
470 rpc_info_.RegisterInterceptors(creators, interceptor_pos);
474 uint32_t initial_metadata_flags()
const {
476 (wait_for_ready_explicitly_set_
481 std::string authority() {
return authority_; }
483 void SendCancelToInterceptors();
485 static std::unique_ptr<ClientContext> FromInternalServerContext(
487 PropagationOptions options);
489 bool initial_metadata_received_;
490 bool wait_for_ready_;
491 bool wait_for_ready_explicitly_set_;
492 std::shared_ptr<grpc::Channel> channel_;
497 grpc::string authority_;
498 std::shared_ptr<grpc::CallCredentials> creds_;
499 mutable std::shared_ptr<const grpc::AuthContext> auth_context_;
501 std::multimap<std::string, std::string> send_initial_metadata_;
506 PropagationOptions propagation_options_;
509 bool initial_metadata_corked_;
511 std::string debug_error_string_;
518 #endif // GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H
Definition: client_callback.h:1113
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:34
static std::unique_ptr< ClientContext > FromServerContext(const grpc::ServerContextBase &server_context, PropagationOptions options=PropagationOptions())
Create a new ClientContext as a child of an incoming server call, according to options (.
grpc_compression_algorithm compression_algorithm() const
Return the compression algorithm the client call will request be used.
Definition: client_context.h:338
void set_credentials(const std::shared_ptr< grpc::CallCredentials > &creds)
Set credentials for the client call.
Definition: client_callback.h:469
Synchronous (blocking) client-side API for doing client-streaming RPCs, where the outgoing message st...
Definition: channel_interface.h:33
virtual void Destructor(ClientContext *context)=0
An Alarm posts the user-provided tag to its associated completion queue or invokes the user-provided ...
Definition: alarm.h:33
void set_wait_for_ready(bool wait_for_ready)
Trigger wait-for-ready or not on this request.
Definition: client_context.h:285
Definition: server_context.h:606
void set_deadline(const T &deadline)
Set the deadline for the client call.
Definition: client_context.h:274
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level)
Definition: compression_types.h:60
virtual ~GlobalCallbacks()
Definition: client_context.h:399
Definition: channel_interface.h:69
Options for ClientContext::FromServerContext specifying which traits from the ServerContext to propag...
Definition: client_context.h:129
Base class of ServerContext.
Definition: server_context.h:126
virtual void DefaultConstructor(ClientContext *context)=0
std::string peer() const
Return the peer uri in a string.
const std::multimap< grpc::string_ref, grpc::string_ref > & GetServerInitialMetadata() const
Return a collection of initial metadata key-value pairs.
Definition: client_context.h:250
gpr_timespec raw_deadline() const
Return a gpr_timespec representation of the client call's deadline.
Definition: client_context.h:299
PropagationOptions()
Definition: client_context.h:131
PropagationOptions & disable_census_stats_propagation()
Definition: client_context.h:148
void set_census_context(struct census_context *ccp)
Sets the census context.
Definition: client_context.h:375
void AddMetadata(const std::string &meta_key, const std::string &meta_value)
Add the (meta_key, meta_value) pair to the metadata associated with a client call.
PropagationOptions & disable_census_tracing_propagation()
Definition: client_context.h:158
const std::multimap< grpc::string_ref, grpc::string_ref > & GetServerTrailingMetadata() const
Return a collection of trailing metadata key-value pairs.
Definition: client_context.h:262
Definition: client_interceptor.h:66
#define GRPC_INITIAL_METADATA_WAIT_FOR_READY
Initial metadata flags.
Definition: grpc_types.h:529
Synchronous (blocking) client-side API for doing server-streaming RPCs, where the stream of messages ...
Definition: channel_interface.h:31
std::shared_ptr< const AuthContext > CreateAuthContext(grpc_call *call)
#define GRPC_INITIAL_METADATA_WAIT_FOR_READY_EXPLICITLY_SET
Signal that GRPC_INITIAL_METADATA_WAIT_FOR_READY was explicitly set by the calling application.
Definition: grpc_types.h:532
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:195
PropagationOptions & disable_deadline_propagation()
Definition: client_context.h:138
Async API for client-side unary RPCs, where the message response received from the server is of type ...
Definition: client_context.h:93
struct grpc_call grpc_call
A Call represents an RPC.
Definition: grpc_types.h:70
void TryCancel()
Send a best-effort out-of-band cancel on the call associated with this client context.
friend class grpc::testing::ClientContextTestPeer
Definition: client_context.h:422
Definition: channel_interface.h:38
gpr_timespec raw_time()=delete
#define GRPC_PROPAGATE_CENSUS_STATS_CONTEXT
Propagate census context.
Definition: propagation_bits.h:35
Async client-side API for doing server-streaming RPCs, where the incoming message stream coming from ...
Definition: client_context.h:87
friend class grpc::testing::InteropClientContextInspector
Definition: client_context.h:421
Codegen interface for grpc::Channel.
Definition: channel_interface.h:73
static void SetGlobalCallbacks(GlobalCallbacks *callbacks)
Definition: async_unary_call.h:78
Definition: client_callback.h:885
std::chrono::system_clock::time_point deadline() const
Return the deadline for the client call.
Definition: client_context.h:294
RpcType
Definition: rpc_method.h:33
PropagationOptions & enable_cancellation_propagation()
Definition: client_context.h:163
PropagationOptions & enable_deadline_propagation()
Definition: client_context.h:133
friend class grpc::internal::ClientContextAccessor
Definition: client_context.h:452
Async API on the client side for doing client-streaming RPCs, where the outgoing message stream going...
Definition: client_context.h:89
void set_fail_fast(bool fail_fast)
DEPRECATED: Use set_wait_for_ready() instead.
Definition: client_context.h:291
#define GRPC_PROPAGATE_DEFAULTS
Default propagation mask: clients of the core API are encouraged to encode deltas from this in their ...
Definition: propagation_bits.h:45
uint32_t c_bitmask() const
Definition: client_context.h:173
Async client-side interface for bi-directional streaming, where the outgoing message stream going to ...
Definition: client_context.h:91
PropagationOptions & enable_census_tracing_propagation()
Definition: client_context.h:153
Definition: client_interceptor.h:46
void set_initial_metadata_corked(bool corked)
Flag whether the initial metadata should be corked.
Definition: client_context.h:357
#define GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT
Definition: propagation_bits.h:36
Synchronous (blocking) client-side API for bi-directional streaming RPCs, where the outgoing message ...
Definition: channel_interface.h:35
Global Callbacks.
Definition: client_context.h:397
static std::unique_ptr< ClientContext > FromCallbackServerContext(const grpc::CallbackServerContext &server_context, PropagationOptions options=PropagationOptions())
Definition: call_op_set.h:776
Channels represent a connection to an endpoint. Created by CreateChannel.
Definition: channel.h:54
Definition: client_callback.h:726
std::shared_ptr< const grpc::AuthContext > auth_context() const
Return the authentication context for the associated client call.
Definition: client_context.h:309
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:151
PropagationOptions & enable_census_stats_propagation()
Definition: client_context.h:143
PropagationOptions & disable_cancellation_propagation()
Definition: client_context.h:168
#define GRPC_PROPAGATE_DEADLINE
Propagation bits: this can be bitwise or-ed to form propagation_mask for grpc_call.
Definition: propagation_bits.h:33
Analogous to struct timespec.
Definition: gpr_types.h:50
std::shared_ptr< grpc::CallCredentials > credentials()
EXPERIMENTAL debugging API.
Definition: client_context.h:333
void set_authority(const std::string &authority)
Set the per call authority header (see https://tools.ietf.org/html/rfc7540#section-8....
Definition: client_context.h:303
std::string debug_error_string() const
EXPERIMENTAL debugging API.
Definition: client_context.h:414
struct census_context * census_context() const
Returns the census context that has been set, or nullptr if not set.
Definition: client_context.h:378
std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t)
If you are trying to use CompletionQueue::AsyncNext with a time class that isn't either gpr_timespec ...
Definition: time.h:42
grpc_call * c_call()
Should be used for framework-level extensions only.
Definition: client_context.h:407
void set_compression_algorithm(grpc_compression_algorithm algorithm)
Set algorithm to be the compression algorithm used for the client call.
#define GRPC_PROPAGATE_CANCELLATION
Propagate cancellation.
Definition: propagation_bits.h:38