GRPC C++
1.13.0-dev
|
A ServerContext allows the person implementing a service handler to: More...
#include <server_context.h>
Public Member Functions | |
ServerContext () | |
~ServerContext () | |
std::chrono::system_clock::time_point | deadline () const |
Return the deadline for the server call. More... | |
gpr_timespec | raw_deadline () const |
Return a gpr_timespec representation of the server call's deadline. More... | |
void | AddInitialMetadata (const grpc::string &key, const grpc::string &value) |
Add the (meta_key, meta_value) pair to the initial metadata associated with a server call. More... | |
void | AddTrailingMetadata (const grpc::string &key, const grpc::string &value) |
Add the (meta_key, meta_value) pair to the initial metadata associated with a server call. More... | |
bool | IsCancelled () const |
IsCancelled is always safe to call when using sync API. More... | |
void | TryCancel () const |
Cancel the Call from the server. More... | |
const std::multimap< grpc::string_ref, grpc::string_ref > & | client_metadata () const |
Return a collection of initial metadata key-value pairs sent from the client. More... | |
grpc_compression_level | compression_level () const |
Return the compression algorithm to be used by the server call. More... | |
void | set_compression_level (grpc_compression_level level) |
Set algorithm to be the compression algorithm used for the server call. More... | |
bool | compression_level_set () const |
Return a bool indicating whether the compression level for this call has been set (either implicitly or through a previous call to set_compression_level. More... | |
grpc_compression_algorithm | compression_algorithm () const |
Return the compression algorithm the server call will request be used. More... | |
void | set_compression_algorithm (grpc_compression_algorithm algorithm) |
Set algorithm to be the compression algorithm used for the server call. More... | |
void | SetLoadReportingCosts (const std::vector< grpc::string > &cost_data) |
Set the load reporting costs in cost_data for the call. More... | |
std::shared_ptr< const AuthContext > | auth_context () const |
Return the authentication context for this server call. More... | |
grpc::string | peer () const |
Return the peer uri in a string. More... | |
const struct census_context * | census_context () const |
Get the census context associated with this server call. More... | |
void | AsyncNotifyWhenDone (void *tag) |
Async only. More... | |
grpc_call * | c_call () |
Should be used for framework-level extensions only. More... | |
Friends | |
class | ::grpc::testing::InteropServerContextInspector |
class | ::grpc::testing::ServerContextTestSpouse |
class | ::grpc::ServerInterface |
class | ::grpc::Server |
template<class W , class R > | |
class | ::grpc::ServerAsyncReader |
template<class W > | |
class | ::grpc::ServerAsyncWriter |
template<class W > | |
class | ::grpc::ServerAsyncResponseWriter |
template<class W , class R > | |
class | ::grpc::ServerAsyncReaderWriter |
template<class R > | |
class | ::grpc::ServerReader |
template<class W > | |
class | ::grpc::ServerWriter |
template<class W , class R > | |
class | ::grpc::internal::ServerReaderWriterBody |
template<class ServiceType , class RequestType , class ResponseType > | |
class | ::grpc::internal::RpcMethodHandler |
template<class ServiceType , class RequestType , class ResponseType > | |
class | ::grpc::internal::ClientStreamingHandler |
template<class ServiceType , class RequestType , class ResponseType > | |
class | ::grpc::internal::ServerStreamingHandler |
template<class Streamer , bool WriteNeeded> | |
class | ::grpc::internal::TemplatedBidiStreamingHandler |
class | ::grpc::internal::UnknownMethodHandler |
class | ::grpc::ClientContext |
A ServerContext allows the person implementing a service handler to:
Context settings are only relevant to the call handler they are supplied to, that is to say, they aren't sticky across multiple calls. Some of these settings, such as the compression options, can be made persistent at server construction time by specifying the appropriate ChannelArguments to a grpc::ServerBuilder, via ServerBuilder::AddChannelArgument.
grpc::ServerContext::ServerContext | ( | ) |
grpc::ServerContext::~ServerContext | ( | ) |
void grpc::ServerContext::AddInitialMetadata | ( | const grpc::string & | key, |
const grpc::string & | value | ||
) |
Add the (meta_key, meta_value) pair to the initial metadata associated with a server call.
These are made available at the client side by the grpc::ClientContext::GetServerInitialMetadata() method.
meta_key | The metadata key. If meta_value 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". |
void grpc::ServerContext::AddTrailingMetadata | ( | const grpc::string & | key, |
const grpc::string & | value | ||
) |
Add the (meta_key, meta_value) pair to the initial metadata associated with a server call.
These are made available at the client side by the grpc::ClientContext::GetServerTrailingMetadata() method.
meta_key | The metadata key. If meta_value 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". |
|
inline |
Async only.
Has to be called before the rpc starts. Returns the tag in completion queue when the rpc finishes. IsCancelled() can then be called to check whether the rpc was cancelled.
|
inline |
Return the authentication context for this server call.
|
inline |
Should be used for framework-level extensions only.
Applications never need to call this method.
const struct census_context* grpc::ServerContext::census_context | ( | ) | const |
Get the census context associated with this server call.
|
inline |
Return a collection of initial metadata key-value pairs sent from the client.
Note that keys may happen more than once (ie, a std::multimap is returned).
It is safe to use this method after initial metadata has been received, Calls always begin with the client sending initial metadata, so this is safe to access as soon as the call has begun on the server side.
|
inline |
Return the compression algorithm the server call will request be used.
Note that the gRPC runtime may decide to ignore this request, for example, due to resource constraints, or if the server is aware the client doesn't support the requested algorithm.
|
inline |
Return the compression algorithm to be used by the server call.
|
inline |
Return a bool indicating whether the compression level for this call has been set (either implicitly or through a previous call to set_compression_level.
|
inline |
Return the deadline for the server call.
bool grpc::ServerContext::IsCancelled | ( | ) | const |
IsCancelled is always safe to call when using sync API.
When using async API, it is only safe to call IsCancelled after the AsyncNotifyWhenDone tag has been delivered.
grpc::string grpc::ServerContext::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.
|
inline |
Return a gpr_timespec representation of the server call's deadline.
void grpc::ServerContext::set_compression_algorithm | ( | grpc_compression_algorithm | algorithm | ) |
Set algorithm to be the compression algorithm used for the server call.
algorithm | The compression algorithm used for the server call. |
|
inline |
Set algorithm to be the compression algorithm used for the server call.
algorithm | The compression algorithm used for the server call. |
void grpc::ServerContext::SetLoadReportingCosts | ( | const std::vector< grpc::string > & | cost_data | ) |
Set the load reporting costs in cost_data for the call.
void grpc::ServerContext::TryCancel | ( | ) | const |
Cancel the Call from the server.
This is a best-effort API and depending on when it is called, the RPC may still appear successful to the client. For example, if TryCancel() is called on a separate thread, it might race with the server handler which might return success to the client before TryCancel() was even started by the thread.
It is the caller's responsibility to prevent such races and ensure that if TryCancel() is called, the serverhandler must return Status::CANCELLED. The only exception is that if the serverhandler is already returning an error status code, it is ok to not return Status::CANCELLED even if TryCancel() was called.
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).
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |
|
friend |