GRPC C++  0.11.0.0
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Friends
grpc::ClientContext Class Reference

#include <client_context.h>

Public Member Functions

 ClientContext ()
 
 ~ClientContext ()
 
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. More...
 
const std::multimap
< grpc::string_ref,
grpc::string_ref > & 
GetServerInitialMetadata ()
 Return a collection of initial metadata key-value pairs. More...
 
const std::multimap
< grpc::string_ref,
grpc::string_ref > & 
GetServerTrailingMetadata ()
 Return a collection of trailing metadata key-value pairs. More...
 
template<typename T >
void set_deadline (const T &deadline)
 Set the deadline for the client call. More...
 
std::chrono::system_clock::time_point deadline ()
 Return the deadline for the client call. More...
 
gpr_timespec raw_deadline ()
 Return a gpr_timespec representation of the client call's deadline. More...
 
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). More...
 
std::shared_ptr< const
AuthContext
auth_context () const
 Return the authentication context for this client call. More...
 
void set_credentials (const std::shared_ptr< Credentials > &creds)
 Set credentials for the client call. More...
 
grpc_compression_algorithm compression_algorithm () const
 Return the compression algorithm to be used by the client call. More...
 
void set_compression_algorithm (grpc_compression_algorithm algorithm)
 Set algorithm to be the compression algorithm used for the client call. More...
 
grpc::string peer () const
 Return the peer uri in a string. More...
 
void set_census_context (struct census_context *ccp)
 Get and set census context. More...
 
struct census_context * census_context () const
 
void TryCancel ()
 Send a best-effort out-of-band cancel. More...
 

Static Public Member Functions

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 (. More...
 

Friends

class ::grpc::testing::InteropClientContextInspector
 
class CallOpClientRecvStatus
 
class CallOpRecvInitialMetadata
 
class Channel
 
template<class R >
class ::grpc::ClientReader
 
template<class W >
class ::grpc::ClientWriter
 
template<class R , class W >
class ::grpc::ClientReaderWriter
 
template<class R >
class ::grpc::ClientAsyncReader
 
template<class W >
class ::grpc::ClientAsyncWriter
 
template<class R , class W >
class ::grpc::ClientAsyncReaderWriter
 
template<class R >
class ::grpc::ClientAsyncResponseReader
 
template<class InputMessage , class OutputMessage >
Status BlockingUnaryCall (Channel *channel, const RpcMethod &method, ClientContext *context, const InputMessage &request, OutputMessage *result)
 

Constructor & Destructor Documentation

grpc::ClientContext::ClientContext ( )
grpc::ClientContext::~ClientContext ( )

Member Function Documentation

void grpc::ClientContext::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.

These are made available at the server side by the grpc::ServerContext::client_metadata() method.

Warning
This method should only be called before invoking the rpc.
Parameters
meta_keyThe metadata key. If meta_value is binary data, it must end in "-bin".
meta_valueThe metadata value. If its value is binary, it must be base64-encoding (see https://tools.ietf.org/html/rfc4648#section-4) and meta_key must end in "-bin".
std::shared_ptr<const AuthContext> grpc::ClientContext::auth_context ( ) const

Return the authentication context for this client call.

See Also
grpc::AuthContext.
struct census_context* grpc::ClientContext::census_context ( ) const
inline
grpc_compression_algorithm grpc::ClientContext::compression_algorithm ( ) const
inline

Return the compression algorithm to be used by the client call.

std::chrono::system_clock::time_point grpc::ClientContext::deadline ( )
inline

Return the deadline for the client call.

static std::unique_ptr<ClientContext> grpc::ClientContext::FromServerContext ( const ServerContext server_context,
PropagationOptions  options = PropagationOptions() 
)
static

Create a new ClientContext as a child of an incoming server call, according to options (.

See Also
PropagationOptions).
Parameters
server_contextThe source server context to use as the basis for constructing the client context.
optionsThe options controlling what to copy from the server_context.
Returns
A newly constructed ClientContext instance based on server_context, with traits propagated (copied) according to options.
const std::multimap<grpc::string_ref, grpc::string_ref>& grpc::ClientContext::GetServerInitialMetadata ( )
inline

Return a collection of initial metadata key-value pairs.

Note that keys may happen more than once (ie, a std::multimap is returned).

Warning
This method should only be called after initial metadata has been received. For streaming calls, see ClientReaderInterface::WaitForInitialMetadata().
Returns
A multimap of initial metadata key-value pairs from the server.
const std::multimap<grpc::string_ref, grpc::string_ref>& grpc::ClientContext::GetServerTrailingMetadata ( )
inline

Return a collection of trailing metadata key-value pairs.

Note that keys may happen more than once (ie, a std::multimap is returned).

Warning
This method is only callable once the stream has finished.
Returns
A multimap of metadata trailing key-value pairs from the server.
grpc::string grpc::ClientContext::peer ( ) const

Return the peer uri in a string.

Warning
This value is never authenticated or subject to any security related code. It must not be used for any authentication related functionality. Instead, use auth_context.
Returns
The call's peer URI.
gpr_timespec grpc::ClientContext::raw_deadline ( )
inline

Return a gpr_timespec representation of the client call's deadline.

void grpc::ClientContext::set_authority ( const grpc::string authority)
inline

Set the per call authority header (see https://tools.ietf.org/html/rfc7540#section-8.1.2.3).

void grpc::ClientContext::set_census_context ( struct census_context ccp)
inline

Get and set census context.

void grpc::ClientContext::set_compression_algorithm ( grpc_compression_algorithm  algorithm)

Set algorithm to be the compression algorithm used for the client call.

Parameters
algorithThe compression algorithm used for the client call.
void grpc::ClientContext::set_credentials ( const std::shared_ptr< Credentials > &  creds)
inline

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.

See Also
https://github.com/grpc/grpc/blob/master/doc/grpc-auth-support.md
template<typename T >
void grpc::ClientContext::set_deadline ( const T &  deadline)
inline

Set the deadline for the client call.

Warning
This method should only be called before invoking the rpc.
Parameters
deadlinethe deadline for the client call. Units are determined by the type used.
void grpc::ClientContext::TryCancel ( )

Send a best-effort out-of-band cancel.

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.

Friends And Related Function Documentation

template<class R >
friend class ::grpc::ClientAsyncReader
friend
template<class R , class W >
friend class ::grpc::ClientAsyncReaderWriter
friend
template<class R >
friend class ::grpc::ClientAsyncResponseReader
friend
template<class W >
friend class ::grpc::ClientAsyncWriter
friend
template<class R >
friend class ::grpc::ClientReader
friend
template<class R , class W >
friend class ::grpc::ClientReaderWriter
friend
template<class W >
friend class ::grpc::ClientWriter
friend
friend class ::grpc::testing::InteropClientContextInspector
friend
template<class InputMessage , class OutputMessage >
Status BlockingUnaryCall ( Channel channel,
const RpcMethod method,
ClientContext context,
const InputMessage &  request,
OutputMessage *  result 
)
friend
friend class CallOpClientRecvStatus
friend
friend class CallOpRecvInitialMetadata
friend
friend class Channel
friend

The documentation for this class was generated from the following file: