Apache Mesos
Classes | Public Member Functions | List of all members
process::grpc::client::Runtime Class Reference

A copyable interface to manage an internal gRPC runtime instance for asynchronous gRPC calls. More...

#include <grpc.hpp>

Public Member Functions

 Runtime ()
 
template<typename Stub , typename Request , typename Response >
Future< RpcResult< Response > > call (const Channel &channel, std::unique_ptr<::grpc::ClientAsyncResponseReader< Response >>(Stub::*rpc)(::grpc::ClientContext *, const Request &,::grpc::CompletionQueue *), const Request &request)
 Sends an asynchronous gRPC call. More...
 
void terminate ()
 Asks the internal gRPC runtime instance to shut down the CompletionQueue, which would stop its looper thread, drain and fail all pending gRPC calls in the CompletionQueue, then asynchronously join the looper thread. More...
 
Future< Nothingwait ()
 

Detailed Description

A copyable interface to manage an internal gRPC runtime instance for asynchronous gRPC calls.

A gRPC runtime instance includes a gRPC CompletionQueue to manage outstanding requests, a looper thread to wait for any incoming responses from the CompletionQueue, and a process to handle the responses. All Runtime copies share the same gRPC runtime instance. Usually we only need a single gRPC runtime instance to handle all gRPC calls, but multiple instances can be instantiated for more parallelism or isolation. NOTE: The destruction of the internal gRPC runtime instance is a blocking operation: it waits for the managed process to terminate. The user should ensure that this only happens at shutdown.

Constructor & Destructor Documentation

process::grpc::client::Runtime::Runtime ( )
inline

Member Function Documentation

template<typename Stub , typename Request , typename Response >
Future<RpcResult<Response> > process::grpc::client::Runtime::call ( const Channel channel,
std::unique_ptr<::grpc::ClientAsyncResponseReader< Response >>(Stub::*)(::grpc::ClientContext *, const Request &,::grpc::CompletionQueue *)  rpc,
const Request &  request 
)
inline

Sends an asynchronous gRPC call.

Parameters
channelA connection to a gRPC server.
rpcThe asynchronous gRPC call to make. This can be obtained by the GRPC_RPC(Service, RPC) macro.
requestThe request protobuf for the gRPC call.
Returns
a Future waiting for a response protobuf.
void process::grpc::client::Runtime::terminate ( )

Asks the internal gRPC runtime instance to shut down the CompletionQueue, which would stop its looper thread, drain and fail all pending gRPC calls in the CompletionQueue, then asynchronously join the looper thread.

Future<Nothing> process::grpc::client::Runtime::wait ( )
Returns
A Future waiting for all pending gRPC calls in the CompletionQueue of the internal gRPC runtime instance to be drained and the looper thread to be joined.

The documentation for this class was generated from the following file: