49 #ifndef GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H
50 #define GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H
62 #include <grpc/impl/codegen/compression_types.h>
63 #include <grpc/impl/codegen/log.h>
64 #include <grpc/impl/codegen/propagation_bits.h>
65 #include <grpc/impl/codegen/time.h>
67 struct census_context;
73 class ChannelInterface;
74 class CompletionQueue;
75 class CallCredentials;
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;
103 propagate_ |= GRPC_PROPAGATE_DEADLINE;
108 propagate_ &= ~GRPC_PROPAGATE_DEADLINE;
113 propagate_ |= GRPC_PROPAGATE_CENSUS_STATS_CONTEXT;
118 propagate_ &= ~GRPC_PROPAGATE_CENSUS_STATS_CONTEXT;
123 propagate_ |= GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT;
128 propagate_ &= ~GRPC_PROPAGATE_CENSUS_TRACING_CONTEXT;
133 propagate_ |= GRPC_PROPAGATE_CANCELLATION;
138 propagate_ &= ~GRPC_PROPAGATE_CANCELLATION;
149 class InteropClientContextInspector;
193 const std::multimap<grpc::string_ref, grpc::string_ref>&
195 GPR_ASSERT(initial_metadata_received_);
196 return recv_initial_metadata_;
205 const std::multimap<grpc::string_ref, grpc::string_ref>&
208 return trailing_metadata_;
217 template <
typename T>
223 #ifndef GRPC_CXX0X_NO_CHRONO
224 std::chrono::system_clock::time_point
deadline() {
228 #endif // !GRPC_CXX0X_NO_CHRONO
240 std::shared_ptr<const AuthContext>
auth_context()
const;
256 return compression_algorithm_;
276 return census_context_;
302 friend class ::grpc::testing::InteropClientContextInspector;
307 friend class ::grpc::ClientReader;
309 friend class ::grpc::ClientWriter;
310 template <
class W,
class R>
311 friend class ::grpc::ClientReaderWriter;
313 friend class ::grpc::ClientAsyncReader;
315 friend class ::grpc::ClientAsyncWriter;
316 template <
class W,
class R>
317 friend class ::grpc::ClientAsyncReaderWriter;
319 friend class ::grpc::ClientAsyncResponseReader;
320 template <
class InputMessage,
class OutputMessage>
324 const InputMessage& request,
325 OutputMessage* result);
327 grpc_call* call() {
return call_; }
328 void set_call(grpc_call* call,
const std::shared_ptr<Channel>& channel);
332 bool initial_metadata_received_;
333 std::shared_ptr<Channel> channel_;
337 gpr_timespec deadline_;
339 std::shared_ptr<CallCredentials> creds_;
340 mutable std::shared_ptr<const AuthContext> auth_context_;
342 std::multimap<grpc::string, grpc::string> send_initial_metadata_;
343 std::multimap<grpc::string_ref, grpc::string_ref> recv_initial_metadata_;
344 std::multimap<grpc::string_ref, grpc::string_ref> trailing_metadata_;
346 grpc_call* propagate_from_call_;
347 PropagationOptions propagation_options_;
349 grpc_compression_algorithm compression_algorithm_;
354 #endif // GRPCXX_IMPL_CODEGEN_CLIENT_CONTEXT_H
PropagationOptions & enable_census_tracing_propagation()
Definition: client_context.h:122
PropagationOptions & enable_deadline_propagation()
Definition: client_context.h:102
std::string string
Definition: config.h:112
std::chrono::system_clock::time_point deadline()
Return the deadline for the client call.
Definition: client_context.h:225
const std::multimap< grpc::string_ref, grpc::string_ref > & GetServerTrailingMetadata()
Return a collection of trailing metadata key-value pairs.
Definition: client_context.h:206
void set_deadline(const T &deadline)
Set the deadline for the client call.
Definition: client_context.h:218
Definition: sync_no_cxx11.h:45
grpc::string peer() const
Return the peer uri in a string.
PropagationOptions & disable_cancellation_propagation()
Definition: client_context.h:137
PropagationOptions & enable_census_stats_propagation()
Definition: client_context.h:112
gpr_timespec raw_time()
Definition: time.h:57
PropagationOptions & enable_cancellation_propagation()
Definition: client_context.h:132
virtual void Destructor(ClientContext *context)=0
Definition: client_context.h:152
std::shared_ptr< const AuthContext > auth_context() const
Return the authentication context for this client call.
struct census_context * census_context() const
Definition: client_context.h:275
void TryCancel()
Send a best-effort out-of-band cancel.
Options for ClientContext::FromServerContext specifying which traits from the ServerContext to propag...
Definition: client_context.h:98
void set_census_context(struct census_context *ccp)
Get and set census context.
Definition: client_context.h:274
const std::multimap< grpc::string_ref, grpc::string_ref > & GetServerInitialMetadata()
Return a collection of initial metadata key-value pairs.
Definition: client_context.h:194
Global Callbacks.
Definition: client_context.h:289
grpc_compression_algorithm compression_algorithm() const
Return the compression algorithm to be used by the client call.
Definition: client_context.h:255
friend Status BlockingUnaryCall(ChannelInterface *channel, const RpcMethod &method, ClientContext *context, const InputMessage &request, OutputMessage *result)
Definition: client_unary_call.h:51
Codegen interface for grpc::Channel.
Definition: channel_interface.h:64
Definition: server_context.h:90
static void SetGlobalCallbacks(GlobalCallbacks *callbacks)
PropagationOptions & disable_census_tracing_propagation()
Definition: client_context.h:127
Definition: rpc_method.h:43
void set_authority(const grpc::string &authority)
Set the per call authority header (see https://tools.ietf.org/html/rfc7540#section-8.1.2.3).
Definition: client_context.h:235
gpr_timespec raw_deadline()
Return a gpr_timespec representation of the client call's deadline.
Definition: client_context.h:231
Did it work? If it didn't, why?
Definition: status.h:45
std::chrono::system_clock::time_point Timespec2Timepoint(gpr_timespec t)
virtual void DefaultConstructor(ClientContext *context)=0
PropagationOptions()
Definition: client_context.h:100
uint32_t c_bitmask() const
Definition: client_context.h:142
void set_credentials(const std::shared_ptr< CallCredentials > &creds)
Set credentials for the client call.
Definition: client_context.h:250
void set_compression_algorithm(grpc_compression_algorithm algorithm)
Set algorithm to be the compression algorithm used for the client call.
PropagationOptions & disable_deadline_propagation()
Definition: client_context.h:107
static std::unique_ptr< ClientContext > FromServerContext(const ServerContext &server_context, PropagationOptions options=PropagationOptions())
Create a new ClientContext as a child of an incoming server call, according to options (...
void AddMetadata(const grpc::string &meta_key, const grpc::string &meta_value)
Add the (meta_key, meta_value) pair to the metadata associated with a client call.
PropagationOptions & disable_census_stats_propagation()
Definition: client_context.h:117
virtual ~GlobalCallbacks()
Definition: client_context.h:291
Channels represent a connection to an endpoint. Created by CreateChannel.
Definition: channel.h:49