Merge pull request #24420 from vjpai/sync_client_code_size_v2

Reduce sync client templating for protobuf without protobuf dependence
pull/24491/head
Vijay Pai 4 years ago committed by GitHub
commit 97924fcfb2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 17
      include/grpcpp/impl/codegen/client_unary_call.h
  2. 2
      src/compiler/cpp_generator.cc

@ -30,12 +30,23 @@ namespace grpc {
class ClientContext;
namespace internal {
class RpcMethod;
/// Wrapper that performs a blocking unary call
template <class InputMessage, class OutputMessage>
/// Wrapper that performs a blocking unary call. May optionally specify the base
/// class of the Request and Response so that the internal calls and structures
/// below this may be based on those base classes and thus achieve code reuse
/// across different RPCs (e.g., for protobuf, MessageLite would be a base
/// class).
template <class InputMessage, class OutputMessage,
class BaseInputMessage = InputMessage,
class BaseOutputMessage = OutputMessage>
Status BlockingUnaryCall(ChannelInterface* channel, const RpcMethod& method,
grpc::ClientContext* context,
const InputMessage& request, OutputMessage* result) {
return BlockingUnaryCallImpl<InputMessage, OutputMessage>(
static_assert(std::is_base_of<BaseInputMessage, InputMessage>::value,
"Invalid input message specification");
static_assert(std::is_base_of<BaseOutputMessage, OutputMessage>::value,
"Invalid output message specification");
return BlockingUnaryCallImpl<BaseInputMessage, BaseOutputMessage>(
channel, method, context, request, result)
.status();
}

@ -1887,6 +1887,8 @@ void PrintSourceClientMethod(grpc_generator::Printer* printer,
"const $Request$& request, $Response$* response) {\n");
printer->Print(*vars,
" return ::grpc::internal::BlockingUnaryCall"
"< $Request$, $Response$, ::grpc::protobuf::MessageLite, "
"::grpc::protobuf::MessageLite>"
"(channel_.get(), rpcmethod_$Method$_, "
"context, request, response);\n}\n\n");

Loading…
Cancel
Save