6 #ifndef IROHA_ASYNC_GRPC_CLIENT_HPP 7 #define IROHA_ASYNC_GRPC_CLIENT_HPP 12 #include <google/protobuf/empty.pb.h> 13 #include <grpc++/grpc++.h> 14 #include <grpcpp/impl/codegen/async_unary_call.h> 24 template <
typename Response>
29 log_(
std::move(log)) {}
37 while (
cq_.Next(&got_tag, &ok)) {
39 if (not call->status.ok()) {
40 log_->warn(
"RPC failed: {}", call->status.error_message());
42 if (call->on_response) {
43 call->on_response(call->status, call->reply);
56 grpc::CompletionQueue
cq_;
69 std::unique_ptr<grpc::ClientAsyncResponseReaderInterface<Response>>
86 call->response_reader = lambda(&call->context, &cq_);
87 call->response_reader->Finish(&call->reply, &call->status, call);
96 #endif // IROHA_ASYNC_GRPC_CLIENT_HPP grpc::ClientContext context
Definition: async_grpc_client.hpp:65
AsyncGrpcClient(logger::LoggerPtr log)
Definition: async_grpc_client.hpp:27
Definition: async_grpc_client.hpp:62
Response reply
Definition: async_grpc_client.hpp:63
std::unique_ptr< grpc::ClientAsyncResponseReaderInterface< Response > > response_reader
Definition: async_grpc_client.hpp:70
std::function< void(grpc::Status &, Response &)> on_response
Definition: async_grpc_client.hpp:72
void asyncCompleteRpc()
Definition: async_grpc_client.hpp:34
std::shared_ptr< Logger > LoggerPtr
Definition: logger_fwd.hpp:22
grpc::Status status
Definition: async_grpc_client.hpp:67
Definition: block_query.hpp:15
std::thread thread_
Definition: async_grpc_client.hpp:57
Definition: async_grpc_client.hpp:25
Status
Definition: status.hpp:12
~AsyncGrpcClient()
Definition: async_grpc_client.hpp:49
void Call(F &&lambda, std::function< void(grpc::Status &, Response &)> on_response={})
Definition: async_grpc_client.hpp:81
grpc::CompletionQueue cq_
Definition: async_grpc_client.hpp:56