class ServerContextBase
Defined at line 124 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
Base class of ServerContext.
Public Methods
std::chrono::system_clock::time_point deadline ()
Return the deadline for the server call.
Defined at line 129 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
gpr_timespec raw_deadline ()
Return a
representation of the server call's deadline.
Defined at line 134 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
const std::multimap<grpc::string_ref, grpc::string_ref> & client_metadata ()
Return a collection of initial metadata key-value pairs sent from the
client. Note that keys may happen more than
once (ie, a
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.
Returns
A multimap of initial metadata key-value pairs from the server.
Defined at line 230 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
grpc_compression_level compression_level ()
Return the compression algorithm to be used by the server call.
Defined at line 236 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
void set_compression_level (grpc_compression_level level)
Set
to be the compression level used for the server call.
Parameters
Defined at line 243 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
bool compression_level_set ()
Return a bool indicating whether the compression level for this call
has been set (either implicitly or through a previous call to
Defined at line 251 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
grpc_compression_algorithm compression_algorithm ()
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.
Defined at line 257 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
std::shared_ptr<const grpc::AuthContext> auth_context ()
Return the authentication context for this server call.
Defined at line 271 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
grpc_call * c_call ()
Should be used for framework-level extensions only.
Applications never need to call this method.
Defined at line 289 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
experimental::CallMetricRecorder * ExperimentalGetCallMetricRecorder ()
Get the
object for the current RPC.
Use it to record metrics during your RPC to send back to the
client in order to make load balancing decisions. This will
return nullptr if the feature hasn't been enabled using
Defined at line 296 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
void ~ServerContextBase ()
void AddInitialMetadata (const std::string & key, const std::string & value)
Add the (
pair to the initial metadata
associated with a server call. These are made available at the client side
by the
method.
Metadata must conform to the following format:
Parameters
void AddTrailingMetadata (const std::string & key, const std::string & value)
Add the (
pair to the initial metadata
associated with a server call. These are made available at the client
side by the
method.
Metadata must conform to the following format:
Parameters
bool 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.
void 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. Additionally, it is illegal to invoke TryCancel()
before the call has actually begun, i.e., before metadata has been
received from the client.
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).
void set_compression_algorithm (grpc_compression_algorithm algorithm)
Set
to be the compression algorithm used for the server call.
Parameters
void SetLoadReportingCosts (const std::vector<std::string> & cost_data)
Set the serialized load reporting costs in
for the call.
std::string 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.
const struct census_context * census_context ()
Get the census context associated with this server call.
grpc::string_ref ExperimentalGetAuthority ()
EXPERIMENTAL API
Returns the call's authority.
Protected Methods
void AsyncNotifyWhenDone (void * tag)
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.
Note: the tag will only be returned if call starts.
If the call never starts, this tag will not be returned.
Defined at line 310 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
RpcAllocatorState * GetRpcAllocatorState ()
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.
Defined at line 318 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
grpc::ServerUnaryReactor * DefaultReactor ()
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.
Defined at line 334 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
void set_context_allocator (ContextAllocator * context_allocator)
Defined at line 355 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
ContextAllocator * context_allocator ()
Defined at line 359 of file ../../third_party/grpc-migrating/src/include/grpcpp/server_context.h
void ServerContextBase ()
Constructors for use by derived classes
void ServerContextBase (gpr_timespec deadline, grpc_metadata_array * arr)
Friends
class GenericCallbackServerContext
class GenericServerContext
class ClientContext
template <class Base>
class FinishOnlyReactor
template <grpc::StatusCode code>
class ErrorMethodHandler
template <class RequestType, class ResponseType>
class CallbackBidiHandler
template <class RequestType, class ResponseType>
class CallbackServerStreamingHandler
template <class RequestType, class ResponseType>
class CallbackClientStreamingHandler
template <class RequestType, class ResponseType>
class CallbackUnaryHandler
template <class Streamer, bool WriteNeeded>
class TemplatedBidiStreamingHandler
template <class ServiceType, class RequestType, class ResponseType>
class ServerStreamingHandler
template <class ServiceType, class RequestType, class ResponseType>
class ClientStreamingHandler
template <class ServiceType, class RequestType, class ResponseType, class BaseRequestType, class BaseResponseType>
class RpcMethodHandler
template <class ResponseType>
void ServerContextBase (const internal::MethodHandler::HandlerParameter & param, ResponseType * rsp, Status & status)
template <class W, class R>
class ServerReaderWriterBody
template <class W>
class ServerWriter
template <class R>
class ServerReader
template <class W, class R>
class ServerAsyncReaderWriter
template <class W>
class ServerAsyncResponseWriter
template <class W>
class ServerAsyncWriter
template <class W, class R>
class ServerAsyncReader
class Server
class ServerInterface
class DefaultReactorTestPeer
class ServerContextTestSpouse
class InteropServerContextInspector