|
Apache Mesos
|
A copyable interface to manage an internal runtime process for asynchronous gRPC calls. More...
#include <grpc.hpp>
Public Member Functions | |
| Runtime () | |
| template<typename Method , typename Request = typename internal::MethodTraits<Method>::request_type, typename Response = typename internal::MethodTraits<Method>::response_type, typename std::enable_if< std::is_convertible< typename std::decay< Request >::type *, google::protobuf::Message * >::value, int >::type = 0> | |
| Future< Try< Response, StatusError > > | call (const Connection &connection, Method &&method, Request &&request, const CallOptions &options) |
| Sends an asynchronous gRPC call. More... | |
| void | terminate () |
Asks the internal runtime process to shut down the CompletionQueue, which would asynchronously drain and fail all pending gRPC calls in the CompletionQueue, then join the looper thread. More... | |
| Future< Nothing > | wait () |
A copyable interface to manage an internal runtime process for asynchronous gRPC calls.
A runtime process keeps a gRPC CompletionQueue to manage outstanding requests, a looper thread to wait for any incoming responses from the CompletionQueue, and handles the requests and responses. All Runtime copies share the same runtime process. Usually we only need a single runtime process to handle all gRPC calls, but multiple runtime processes can be instantiated for better parallelism and isolation.
NOTE: The caller must call terminate to drain the CompletionQueue before finalizing libprocess to gracefully terminate the gRPC runtime.
|
inline |
|
inline |
Sends an asynchronous gRPC call.
This function returns a Future of a Try such that the response protobuf is returned only if the gRPC call returns an OK status to ensure type safety (see https://github.com/grpc/grpc/issues/12824). Note that the future never fails; it will return a StatusError if a non-OK status is returned for the call, so the caller can handle the error programmatically.
| connection | A connection to a gRPC server. |
| method | The asynchronous gRPC call to make. This should be obtained by the GRPC_CLIENT_METHOD(service, rpc) macro. |
| request | The request protobuf for the gRPC call. |
| options | The gRPC options for the call. |
| void process::grpc::client::Runtime::terminate | ( | ) |
Asks the internal runtime process to shut down the CompletionQueue, which would asynchronously drain and fail all pending gRPC calls in the CompletionQueue, then join the looper thread.
Future waiting for all pending gRPC calls in the CompletionQueue of the internal runtime process to be drained and the looper thread to be joined.
1.8.11