GRPC C++
1.30.0
|
#include <server_context_impl.h>
Public Member Functions | |
CallbackServerContext () | |
Public constructors are for direct use only by mocking tests. More... | |
void | AddInitialMetadata (const grpc::string &key, const grpc::string &value) |
Add the (key, value) pair to the initial metadata associated with a server call. More... | |
void | AddTrailingMetadata (const grpc::string &key, const grpc::string &value) |
Add the (key, value) pair to the initial metadata associated with a server call. More... | |
std::shared_ptr< const ::grpc::AuthContext > | auth_context () const |
Return the authentication context for this server call. More... | |
grpc_call * | c_call () |
Should be used for framework-level extensions only. More... | |
const struct census_context * | census_context () const |
Get the census context associated with this server call. 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_algorithm | compression_algorithm () const |
Return the compression algorithm the server call will request be used. More... | |
grpc_compression_level | compression_level () const |
Return the compression algorithm to be used by 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... | |
std::chrono::system_clock::time_point | deadline () const |
Return the deadline for the server call. More... | |
bool | IsCancelled () const |
IsCancelled is always safe to call when using sync or callback API. More... | |
grpc::string | peer () const |
Return the peer uri in a string. More... | |
gpr_timespec | raw_deadline () const |
Return a gpr_timespec representation of the server call's deadline. More... | |
void | set_compression_algorithm (grpc_compression_algorithm algorithm) |
Set algorithm to be the compression algorithm used for the server call. More... | |
void | set_compression_level (grpc_compression_level level) |
Set level to be the compression level used for the server call. More... | |
void | SetLoadReportingCosts (const std::vector< grpc::string > &cost_data) |
Set the serialized load reporting costs in cost_data for the call. More... | |
void | TryCancel () const |
Cancel the Call from the server. More... | |
::grpc_impl::ServerUnaryReactor * | DefaultReactor () |
Get a library-owned default unary reactor for use in minimal reaction cases. More... | |
::grpc::experimental::RpcAllocatorState * | GetRpcAllocatorState () |
NOTE: This is an API for advanced users who need custom allocators. More... | |
Public Member Functions inherited from grpc_impl::ServerContextBase | |
virtual | ~ServerContextBase () |
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 (key, value) pair to the initial metadata associated with a server call. More... | |
void | AddTrailingMetadata (const grpc::string &key, const grpc::string &value) |
Add the (key, value) pair to the initial metadata associated with a server call. More... | |
bool | IsCancelled () const |
IsCancelled is always safe to call when using sync or callback 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 level to be the compression level 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 serialized load reporting costs in cost_data for the call. More... | |
std::shared_ptr< const ::grpc::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... | |
grpc_call * | c_call () |
Should be used for framework-level extensions only. More... | |
Additional Inherited Members | |
Protected Member Functions inherited from grpc_impl::ServerContextBase | |
void | AsyncNotifyWhenDone (void *tag) |
Async only. More... | |
::grpc::experimental::RpcAllocatorState * | GetRpcAllocatorState () |
NOTE: This is an API for advanced users who need custom allocators. More... | |
::grpc_impl::ServerUnaryReactor * | DefaultReactor () |
Get a library-owned default unary reactor for use in minimal reaction cases. More... | |
ServerContextBase () | |
Constructors for use by derived classes. More... | |
ServerContextBase (gpr_timespec deadline, grpc_metadata_array *arr) | |
|
inline |
Public constructors are for direct use only by mocking tests.
In practice, these objects will be owned by the library.
void grpc_impl::ServerContextBase::AddInitialMetadata |
Add the (key, 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.
key | The metadata key. If value is binary data, it must end in "-bin". |
value | The metadata value. If its value is binary, the key name must end in "-bin". |
Metadata must conform to the following format: Custom-Metadata -> Binary-Header / ASCII-Header Binary-Header -> {Header-Name "-bin" } {binary value} ASCII-Header -> Header-Name ASCII-Value Header-Name -> 1*( x30-39 / x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . ASCII-Value -> 1*( x20-x7E ) ; space and printable ASCII
void grpc_impl::ServerContextBase::AddTrailingMetadata |
Add the (key, 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.
key | The metadata key. If value is binary data, it must end in "-bin". |
value | The metadata value. If its value is binary, the key name must end in "-bin". |
Metadata must conform to the following format: Custom-Metadata -> Binary-Header / ASCII-Header Binary-Header -> {Header-Name "-bin" } {binary value} ASCII-Header -> Header-Name ASCII-Value Header-Name -> 1*( x30-39 / x61-7A / "_" / "-" / ".") ; 0-9 a-z _ - . ASCII-Value -> 1*( x20-x7E ) ; space and printable ASCII
|
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_impl::ServerContextBase::census_context |
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.
|
inline |
Get a library-owned default unary reactor for use in minimal reaction cases.
This supports typical unary RPC usage of providing a response and status. It supports immediate Finish (finish from within the method handler) or delayed Finish (finish called after the method handler invocation). It does not support reacting to cancellation or completion, or early sending of initial metadata. Since this is a library-owned reactor, it should not be delete'd or freed in any way. This is more efficient than creating a user-owned reactor both because of avoiding an allocation and because its minimal reactions are optimized using a core surface flag that allows their reactions to run inline without any thread-hop.
This method should not be called more than once or called after return from the method handler.
WARNING: This is experimental API and could be changed or removed.
|
inline |
NOTE: This is an API for advanced users who need custom allocators.
Get and maybe mutate the allocator state associated with the current RPC. Currently only applicable for callback unary RPC methods. WARNING: This is experimental API and could be changed or removed.
bool grpc_impl::ServerContextBase::IsCancelled |
IsCancelled is always safe to call when using sync or callback API.
When using async API, it is only safe to call IsCancelled after the AsyncNotifyWhenDone tag has been delivered. Thread-safe.
grpc::string grpc_impl::ServerContextBase::peer |
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_impl::ServerContextBase::set_compression_algorithm |
Set algorithm to be the compression algorithm used for the server call.
algorithm | The compression algorithm used for the server call. |
|
inline |
Set level to be the compression level used for the server call.
level | The compression level used for the server call. |
void grpc_impl::ServerContextBase::SetLoadReportingCosts |
Set the serialized load reporting costs in cost_data for the call.
void grpc_impl::ServerContextBase::TryCancel |
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).