Go to the documentation of this file.
34 #ifndef GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H
35 #define GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H
65 template <
class InputMessage,
class OutputMessage>
66 class CallbackUnaryCallImpl;
67 template <
class Request,
class Response>
68 class ClientCallbackReaderWriterImpl;
69 template <
class Response>
70 class ClientCallbackReaderImpl;
71 template <
class Request>
72 class ClientCallbackWriterImpl;
73 class ClientCallbackUnaryImpl;
74 class ClientContextAccessor;
81 template <
class W,
class R>
82 class ClientReaderWriter;
84 class ClientAsyncReader;
86 class ClientAsyncWriter;
87 template <
class W,
class R>
88 class ClientAsyncReaderWriter;
90 class ClientAsyncResponseReader;
93 class InteropClientContextInspector;
98 template <
class InputMessage,
class OutputMessage>
99 class BlockingUnaryCallImpl;
100 class CallOpClientRecvStatus;
101 class CallOpRecvInitialMetadata;
102 class ServerContextImpl;
103 template <
class InputMessage,
class OutputMessage>
104 class CallbackUnaryCallImpl;
105 template <
class Request,
class Response>
106 class ClientCallbackReaderWriterImpl;
107 template <
class Response>
108 class ClientCallbackReaderImpl;
109 template <
class Request>
110 class ClientCallbackWriterImpl;
111 class ClientCallbackUnaryImpl;
112 class ClientContextAccessor;
115 class CallCredentials;
117 class ChannelInterface;
118 class CompletionQueue;
230 void AddMetadata(
const std::string& meta_key,
const std::string& meta_value);
240 const std::multimap<grpc::string_ref, grpc::string_ref>&
243 return *recv_initial_metadata_.
map();
252 const std::multimap<grpc::string_ref, grpc::string_ref>&
255 return *trailing_metadata_.
map();
264 template <
typename T>
289 wait_for_ready_ = wait_for_ready;
290 wait_for_ready_explicitly_set_ =
true;
297 std::chrono::system_clock::time_point
deadline()
const {
306 void set_authority(
const std::string& authority) { authority_ = authority; }
313 if (auth_context_.get() ==
nullptr) {
316 return auth_context_;
329 void set_credentials(
const std::shared_ptr<grpc::CallCredentials>& creds);
336 std::shared_ptr<grpc::CallCredentials>
credentials() {
return creds_; }
342 return compression_algorithm_;
361 initial_metadata_corked_ = corked;
372 std::string
peer()
const;
382 return census_context_;
424 friend class ::grpc::testing::InteropClientContextInspector;
425 friend class ::grpc::internal::CallOpClientRecvStatus;
426 friend class ::grpc::internal::CallOpRecvInitialMetadata;
427 friend class ::grpc::Channel;
429 friend class ::grpc::ClientReader;
431 friend class ::grpc::ClientWriter;
432 template <
class W,
class R>
433 friend class ::grpc::ClientReaderWriter;
435 friend class ::grpc::ClientAsyncReader;
437 friend class ::grpc::ClientAsyncWriter;
438 template <
class W,
class R>
439 friend class ::grpc::ClientAsyncReaderWriter;
441 friend class ::grpc::ClientAsyncResponseReader;
442 template <
class InputMessage,
class OutputMessage>
443 friend class ::grpc::internal::BlockingUnaryCallImpl;
444 template <
class InputMessage,
class OutputMessage>
445 friend class ::grpc::internal::CallbackUnaryCallImpl;
446 template <
class Request,
class Response>
447 friend class ::grpc::internal::ClientCallbackReaderWriterImpl;
448 template <
class Response>
449 friend class ::grpc::internal::ClientCallbackReaderImpl;
450 template <
class Request>
451 friend class ::grpc::internal::ClientCallbackWriterImpl;
452 friend class ::grpc::internal::ClientCallbackUnaryImpl;
453 friend class ::grpc::internal::ClientContextAccessor;
460 grpc_call* call()
const {
return call_; }
462 const std::shared_ptr<::grpc::Channel>& channel);
467 const std::vector<std::unique_ptr<
469 size_t interceptor_pos) {
471 rpc_info_.RegisterInterceptors(creators, interceptor_pos);
475 uint32_t initial_metadata_flags()
const {
479 (wait_for_ready_explicitly_set_
485 std::string authority() {
return authority_; }
487 void SendCancelToInterceptors();
489 static std::unique_ptr<ClientContext> FromInternalServerContext(
491 PropagationOptions options);
493 bool initial_metadata_received_;
494 bool wait_for_ready_;
495 bool wait_for_ready_explicitly_set_;
498 std::shared_ptr<::grpc::Channel> channel_;
503 grpc::string authority_;
504 std::shared_ptr<grpc::CallCredentials> creds_;
505 mutable std::shared_ptr<const grpc::AuthContext> auth_context_;
507 std::multimap<std::string, std::string> send_initial_metadata_;
512 PropagationOptions propagation_options_;
515 bool initial_metadata_corked_;
517 std::string debug_error_string_;
524 #endif // GRPCPP_IMPL_CODEGEN_CLIENT_CONTEXT_H
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
grpc_compression_algorithm compression_algorithm() const
Return the compression algorithm the client call will request be used.
Definition: client_context.h:341
void set_credentials(const std::shared_ptr< grpc::CallCredentials > &creds)
Set credentials for the client call.
A ServerContext or CallbackServerContext allows the code implementing a service handler to:
Definition: server_context.h:527
virtual void Destructor(ClientContext *context)=0
#define GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST
Initial metadata flags.
Definition: grpc_types.h:477
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)
EXPERIMENTAL: Trigger wait-for-ready or not on this request.
Definition: client_context.h:288
Definition: server_context.h:567
void set_deadline(const T &deadline)
Set the deadline for the client call.
Definition: client_context.h:265
grpc_compression_algorithm
The various compression algorithms supported by gRPC (not sorted by compression level)
Definition: compression_types.h:57
virtual ~GlobalCallbacks()
Definition: client_context.h:402
Options for ClientContext::FromServerContext specifying which traits from the ServerContext to propag...
Definition: client_context.h:125
Base class of ServerContext. Experimental until callback API is final.
Definition: server_context.h:125
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:241
gpr_timespec raw_deadline() const
Return a gpr_timespec representation of the client call's deadline.
Definition: client_context.h:302
::grpc::ServerContextBase ServerContextBase
Definition: server_context.h:102
PropagationOptions()
Definition: client_context.h:127
void set_idempotent(bool idempotent)
EXPERIMENTAL: Indicate that this request is idempotent.
Definition: client_context.h:275
PropagationOptions & disable_census_stats_propagation()
Definition: client_context.h:144
void set_census_context(struct census_context *ccp)
Sets the census context.
Definition: client_context.h:378
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:154
const std::multimap< grpc::string_ref, grpc::string_ref > & GetServerTrailingMetadata() const
Return a collection of trailing metadata key-value pairs.
Definition: client_context.h:253
Definition: client_interceptor.h:66
::grpc::CallbackServerContext CallbackServerContext
Definition: server_context.h:103
#define GRPC_INITIAL_METADATA_WAIT_FOR_READY
Signal that the call should not return UNAVAILABLE before it has started.
Definition: grpc_types.h:479
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:484
A ClientContext allows the person implementing a service client to:
Definition: client_context.h:191
#define GRPC_INITIAL_METADATA_CACHEABLE_REQUEST
Signal that the call is cacheable.
Definition: grpc_types.h:481
PropagationOptions & disable_deadline_propagation()
Definition: client_context.h:134
#define GRPC_INITIAL_METADATA_CORKED
Signal that the initial metadata should be corked.
Definition: grpc_types.h:486
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.
gpr_timespec raw_time()=delete
#define GRPC_PROPAGATE_CENSUS_STATS_CONTEXT
Propagate census context.
Definition: propagation_bits.h:33
Codegen interface for grpc::Channel.
Definition: channel_interface.h:72
static void SetGlobalCallbacks(GlobalCallbacks *callbacks)
static std::unique_ptr< ClientContext > FromServerContext(const grpc::ServerContext &server_context, PropagationOptions options=PropagationOptions())
Create a new ClientContext as a child of an incoming server call, according to options (.
std::chrono::system_clock::time_point deadline() const
Return the deadline for the client call.
Definition: client_context.h:297
RpcType
Definition: rpc_method.h:31
PropagationOptions & enable_cancellation_propagation()
Definition: client_context.h:159
PropagationOptions & enable_deadline_propagation()
Definition: client_context.h:129
void set_fail_fast(bool fail_fast)
DEPRECATED: Use set_wait_for_ready() instead.
Definition: client_context.h:294
#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:43
uint32_t c_bitmask() const
Definition: client_context.h:169
PropagationOptions & enable_census_tracing_propagation()
Definition: client_context.h:149
Definition: client_interceptor.h:46
void set_initial_metadata_corked(bool corked)
Flag whether the initial metadata should be corked.
Definition: client_context.h:360
#define GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT
Definition: propagation_bits.h:34
Global Callbacks.
Definition: client_context.h:400
static std::unique_ptr< ClientContext > FromCallbackServerContext(const grpc::CallbackServerContext &server_context, PropagationOptions options=PropagationOptions())
void set_cacheable(bool cacheable)
EXPERIMENTAL: Set this request to be cacheable.
Definition: client_context.h:280
std::shared_ptr< const grpc::AuthContext > auth_context() const
Return the authentication context for the associated client call.
Definition: client_context.h:312
#define GPR_CODEGEN_ASSERT(x)
Codegen specific version of GPR_ASSERT.
Definition: core_codegen_interface.h:146
PropagationOptions & enable_census_stats_propagation()
Definition: client_context.h:139
PropagationOptions & disable_cancellation_propagation()
Definition: client_context.h:164
#define GRPC_PROPAGATE_DEADLINE
Propagation bits: this can be bitwise or-ed to form propagation_mask for grpc_call.
Definition: propagation_bits.h:31
Analogous to struct timespec.
Definition: gpr_types.h:47
std::shared_ptr< grpc::CallCredentials > credentials()
EXPERIMENTAL debugging API.
Definition: client_context.h:336
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:306
std::string debug_error_string() const
EXPERIMENTAL debugging API.
Definition: client_context.h:417
struct census_context * census_context() const
Returns the census context that has been set, or nullptr if not set.
Definition: client_context.h:381
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:40
grpc_call * c_call()
Should be used for framework-level extensions only.
Definition: client_context.h:410
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:36