class ClientContext

Defined at line 195 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

A ClientContext allows the person implementing a service client to:

- Add custom metadata key-value pairs that will propagated to the server

side.

- Control call settings such as compression and authentication.

- Initial and trailing metadata coming from the server.

- Get performance metrics (ie, census).

Context settings are only relevant to the call they are invoked with, that

is to say, they aren't sticky. Some of these settings, such as the

compression options, can be made persistent at channel construction time

(see

Public Methods

void ClientContext ()
std::unique_ptr<ClientContext> FromServerContext (const grpc::ServerContextBase & server_context, PropagationOptions options)

Create a new

as a child of an incoming server call,

according to

(

Parameters

server_context The source server context to use as the basis for constructing the client context.
options The options controlling what to copy from the

Returns

A newly constructed

instance based on

with traits propagated (copied) according to

std::unique_ptr<ClientContext> FromCallbackServerContext (const grpc::CallbackServerContext & server_context, PropagationOptions options)
void AddMetadata (const std::string & meta_key, const std::string & meta_value)

Add the (

pair to the metadata associated with

a client call. These are made available at the server side by the

method.

Metadata must conform to the following format:

Parameters

meta_key The metadata key. If is binary data, it must end in "-bin".
meta_value The metadata value. If its value is binary, the key name must end in "-bin".
const std::multimap<grpc::string_ref, grpc::string_ref> & GetServerInitialMetadata ()

Return a collection of initial metadata key-value pairs. Note that keys

may happen more than once (ie, a

is returned).

Returns

A multimap of initial metadata key-value pairs from the server.

Defined at line 249 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

const std::multimap<grpc::string_ref, grpc::string_ref> & GetServerTrailingMetadata ()

Return a collection of trailing metadata key-value pairs. Note that keys

may happen more than once (ie, a

is returned).

Returns

A multimap of metadata trailing key-value pairs from the server.

Defined at line 261 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

void TryCancel ()

Send a best-effort out-of-band cancel on the call associated with

this client context. The call could be in any stage; e.g., if it is

already finished, it may still return success.

There is no guarantee the call will be cancelled.

Note that TryCancel() does not change any of the tags that are pending

on the completion queue. All pending tags will still be delivered

(though their ok result may reflect the effect of cancellation).

This method is thread-safe, and can be called multiple times from any

thread.

void SetGlobalCallbacks (GlobalCallbacks * callbacks)
template <typename T>
void set_deadline (const T & deadline)

Set the deadline for the client call.

Parameters

deadline the deadline for the client call. Units are determined by the type used. The deadline is an absolute (not relative) time.

Defined at line 274 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

void set_wait_for_ready (bool wait_for_ready)

Trigger wait-for-ready or not on this request.

See https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md.

If set, if an RPC is made when a channel's connectivity state is

TRANSIENT_FAILURE or CONNECTING, the call will not "fail fast",

and the channel will wait until the channel is READY before making the

call.

Defined at line 285 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

void set_fail_fast (bool fail_fast)

DEPRECATED: Use set_wait_for_ready() instead.

Defined at line 291 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

std::chrono::system_clock::time_point deadline ()

Return the deadline for the client call.

Defined at line 294 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

gpr_timespec raw_deadline ()

Return a

representation of the client call's deadline.

Defined at line 299 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

void set_authority (const std::string & authority)

Set the per call authority header (see

https://tools.ietf.org/html/rfc7540#section-8.1.2.3).

Defined at line 303 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

std::shared_ptr<const grpc::AuthContext> auth_context ()

Return the authentication context for the associated client call.

It is only valid to call this during the lifetime of the client call.

Defined at line 309 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

std::shared_ptr<grpc::CallCredentials> credentials ()

EXPERIMENTAL debugging API

Returns the credentials for the client call. This should be used only in

tests and for diagnostic purposes, and should not be used by application

logic.

Defined at line 333 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

grpc_compression_algorithm compression_algorithm ()

Return the compression algorithm the client call will request be used.

Note that the gRPC runtime may decide to ignore this request, for example,

due to resource constraints.

Defined at line 338 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

void set_compression_algorithm (grpc_compression_algorithm algorithm)

Set

to be the compression algorithm used for the client call.

Parameters

algorithm The compression algorithm used for the client call.
std::string peer ()

Return the peer uri in a string.

It is only valid to call this during the lifetime of the client call.

Returns

The call's peer URI.

void set_initial_metadata_corked (bool corked)

Flag whether the initial metadata should be

If

is true, then the initial metadata will be coalesced with the

write of first message in the stream. As a result, any tag set for the

initial metadata operation (starting a client-streaming or bidi-streaming

RPC) will not actually be sent to the completion queue or delivered

via Next.

Parameters

corked The flag indicating whether the initial metadata is to be corked or not.

Defined at line 357 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

void set_census_context (struct census_context * ccp)

Sets the census context.

It is only valid to call this before the client call is created. A common

place of setting census context is from within the DefaultConstructor

method of GlobalCallbacks.

Defined at line 375 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

struct census_context * census_context ()

Returns the census context that has been set, or nullptr if not set.

Defined at line 378 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

grpc_call * c_call ()

Should be used for framework-level extensions only.

Applications never need to call this method.

Defined at line 408 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

std::string debug_error_string ()

EXPERIMENTAL debugging API

if status is not ok() for an RPC, this will return a detailed string

of the gRPC Core error that led to the failure. It should not be relied

upon for anything other than gaining more debug data in failure cases.

Defined at line 415 of file ../../third_party/grpc-migrating/src/include/grpcpp/client_context.h

void ~ClientContext ()
void set_credentials (const std::shared_ptr<grpc::CallCredentials> & creds)

Set credentials for the client call.

A credentials object encapsulates all the state needed by a client to

authenticate with a server and make various assertions, e.g., about the

client’s identity, role, or whether it is authorized to make a particular

call.

It is legal to call this only before initial metadata is sent.

Records

Friends

class ClientContextAccessor
class ClientCallbackUnaryImpl
template <class Request>
class ClientCallbackWriterImpl
template <class Response>
class ClientCallbackReaderImpl
template <class Request, class Response>
class ClientCallbackReaderWriterImpl
template <class InputMessage, class OutputMessage>
class CallbackUnaryCallImpl
template <class InputMessage, class OutputMessage>
class BlockingUnaryCallImpl
class ClientAsyncResponseReaderHelper
template <class R>
class ClientAsyncResponseReader
template <class W, class R>
class ClientAsyncReaderWriter
template <class W>
class ClientAsyncWriter
template <class R>
class ClientAsyncReader
template <class W, class R>
class ClientReaderWriter
template <class W>
class ClientWriter
template <class R>
class ClientReader
class Channel
class CallOpRecvInitialMetadata
class CallOpClientRecvStatus
class ClientContextTestPeer
class InteropClientContextInspector