#include <server_context.h>
Private Member Functions | |
grpc::ServerUnaryReactor * | DefaultReactor () |
RpcAllocatorState * | GetRpcAllocatorState () |
ServerContext & | operator= (const ServerContext &)=delete |
ServerContext (const ServerContext &)=delete | |
Prevent copying. More... | |
ServerContext (gpr_timespec deadline, grpc_metadata_array *arr) | |
Friends | |
class | grpc::Server |
Additional Inherited Members | |
![]() | |
void | AsyncNotifyWhenDone (void *tag) |
ContextAllocator * | context_allocator () const |
grpc::ServerUnaryReactor * | DefaultReactor () |
RpcAllocatorState * | GetRpcAllocatorState () |
ServerContextBase () | |
Constructors for use by derived classes. More... | |
ServerContextBase (gpr_timespec deadline, grpc_metadata_array *arr) | |
void | set_context_allocator (ContextAllocator *context_allocator) |
A ServerContext or CallbackServerContext allows the code 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.
Definition at line 566 of file grpcpp/impl/codegen/server_context.h.
|
inline |
Definition at line 568 of file grpcpp/impl/codegen/server_context.h.
|
inlineprivate |
Definition at line 594 of file grpcpp/impl/codegen/server_context.h.
|
privatedelete |
Prevent copying.
void grpc::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
Definition at line 330 of file server_context.cc.
void grpc::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
Definition at line 335 of file server_context.cc.
|
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. TODO(vjpai): Fix this so that the tag is returned even if the call never starts (https://github.com/grpc/grpc/issues/10136).
Definition at line 310 of file grpcpp/impl/codegen/server_context.h.
|
inline |
Return the authentication context for this server call.
Definition at line 271 of file grpcpp/impl/codegen/server_context.h.
|
inline |
Should be used for framework-level extensions only. Applications never need to call this method.
Definition at line 289 of file grpcpp/impl/codegen/server_context.h.
const struct census_context * grpc::ServerContextBase::census_context |
Get the census context associated with this server call.
Definition at line 394 of file server_context.cc.
|
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.
Definition at line 230 of file grpcpp/impl/codegen/server_context.h.
|
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.
Definition at line 257 of file grpcpp/impl/codegen/server_context.h.
|
inline |
Return the compression algorithm to be used by the server call.
Definition at line 236 of file grpcpp/impl/codegen/server_context.h.
|
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.
Definition at line 251 of file grpcpp/impl/codegen/server_context.h.
|
inline |
Return the deadline for the server call.
Definition at line 131 of file grpcpp/impl/codegen/server_context.h.
|
inlineprivate |
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.
Definition at line 334 of file grpcpp/impl/codegen/server_context.h.
|
inlineprivate |
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.
Definition at line 318 of file grpcpp/impl/codegen/server_context.h.
bool grpc::ServerContextBase::IsCancelled |
Return whether this RPC failed before the server could provide its status back to the client. This could be because of explicit API cancellation from the client-side or server-side, because of deadline exceeded, network connection reset, HTTP/2 parameter configuration (e.g., max message size, max connection age), etc. It does NOT include failure due to a non-OK status return from the server application's request handler, including Status::CANCELLED.
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.
Definition at line 355 of file server_context.cc.
|
privatedelete |
std::string grpc::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.
Definition at line 384 of file server_context.cc.
|
inline |
Return a gpr_timespec representation of the server call's deadline.
Definition at line 136 of file grpcpp/impl/codegen/server_context.h.
void grpc::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. |
Definition at line 371 of file server_context.cc.
|
inline |
Set level to be the compression level used for the server call.
level | The compression level used for the server call. |
Definition at line 243 of file grpcpp/impl/codegen/server_context.h.
void grpc::ServerContextBase::SetLoadReportingCosts |
Set the serialized load reporting costs in cost_data for the call.
Definition at line 399 of file server_context.cc.
void grpc::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.
For reasons such as the above, it is generally preferred to explicitly finish an RPC by returning Status::CANCELLED rather than using TryCancel.
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).
Definition at line 340 of file server_context.cc.
|
friend |
Definition at line 593 of file grpcpp/impl/codegen/server_context.h.