aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorGravatar Yang Gao <yangg@google.com>2015-02-12 15:21:24 -0800
committerGravatar Yang Gao <yangg@google.com>2015-02-12 15:21:24 -0800
commit068c85b21cb0ae9d08ca2a513904670ccd59269b (patch)
treea55db6138483bee079544b3e61cd7bac13dc62d7 /src
parent5705fe3fca7c9ed042b78dee3c2b89364fe183f8 (diff)
make codegen generate async client calls
Diffstat (limited to 'src')
-rw-r--r--src/compiler/cpp_generator.cc58
-rw-r--r--src/cpp/client/client_unary_call.cc7
2 files changed, 59 insertions, 6 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index aa9be6db87..1ab4c29451 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -183,8 +183,8 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer,
printer->Print(*vars,
"void $Method$(::grpc::ClientContext* context, "
"const $Request$& request, $Response$* response, "
- "::grpc::Status *status, "
- "::grpc::CompletionQueue *cq, void *tag);\n");
+ "::grpc::Status* status, "
+ "::grpc::CompletionQueue* cq, void* tag);\n");
} else if (ClientOnlyStreaming(method)) {
printer->Print(*vars,
"::grpc::ClientWriter< $Request$>* $Method$("
@@ -192,8 +192,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer,
printer->Print(*vars,
"::grpc::ClientAsyncWriter< $Request$>* $Method$("
"::grpc::ClientContext* context, $Response$* response, "
- "::grpc::Status *status, "
- "::grpc::CompletionQueue *cq, void *tag);\n");
+ "::grpc::CompletionQueue* cq, void* tag);\n");
} else if (ServerOnlyStreaming(method)) {
printer->Print(
*vars,
@@ -202,7 +201,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer,
printer->Print(*vars,
"::grpc::ClientAsyncReader< $Response$>* $Method$("
"::grpc::ClientContext* context, const $Request$* request, "
- "::grpc::CompletionQueue *cq, void *tag);\n");
+ "::grpc::CompletionQueue* cq, void* tag);\n");
} else if (BidiStreaming(method)) {
printer->Print(*vars,
"::grpc::ClientReaderWriter< $Request$, $Response$>* "
@@ -210,7 +209,7 @@ void PrintHeaderClientMethod(google::protobuf::io::Printer *printer,
printer->Print(*vars,
"::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* "
"$Method$(::grpc::ClientContext* context, "
- "::grpc::CompletionQueue *cq, void *tag);\n");
+ "::grpc::CompletionQueue* cq, void* tag);\n");
}
}
@@ -378,6 +377,16 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer,
"::grpc::RpcMethod($Service$_method_names[$Idx$]), "
"context, request, response);\n"
"}\n\n");
+ printer->Print(*vars,
+ "void $Service$::Stub::$Method$("
+ "::grpc::ClientContext* context, "
+ "const $Request$& request, $Response$* response, ::grpc::Status* status, "
+ "::grpc::CompletionQueue* cq, void* tag) {\n");
+ printer->Print(*vars,
+ " ::grpc::AsyncUnaryCall(channel(),"
+ "::grpc::RpcMethod($Service$_method_names[$Idx$]), "
+ "context, request, response, status, cq, tag);\n"
+ "}\n\n");
} else if (ClientOnlyStreaming(method)) {
printer->Print(
*vars,
@@ -390,6 +399,18 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer,
"::grpc::RpcMethod::RpcType::CLIENT_STREAMING), "
"context, response);\n"
"}\n\n");
+ printer->Print(
+ *vars,
+ "::grpc::ClientAsyncWriter< $Request$>* $Service$::Stub::$Method$("
+ "::grpc::ClientContext* context, $Response$* response, "
+ "::grpc::CompletionQueue* cq, void* tag) {\n");
+ printer->Print(*vars,
+ " return new ::grpc::ClientAsyncWriter< $Request$>("
+ "channel(), cq, "
+ "::grpc::RpcMethod($Service$_method_names[$Idx$], "
+ "::grpc::RpcMethod::RpcType::CLIENT_STREAMING), "
+ "context, response, tag);\n"
+ "}\n\n");
} else if (ServerOnlyStreaming(method)) {
printer->Print(
*vars,
@@ -402,6 +423,18 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer,
"::grpc::RpcMethod::RpcType::SERVER_STREAMING), "
"context, *request);\n"
"}\n\n");
+ printer->Print(
+ *vars,
+ "::grpc::ClientAsyncReader< $Response$>* $Service$::Stub::$Method$("
+ "::grpc::ClientContext* context, const $Request$* request, "
+ "::grpc::CompletionQueue* cq, void* tag) {\n");
+ printer->Print(*vars,
+ " return new ::grpc::ClientAsyncReader< $Response$>("
+ "channel(), cq, "
+ "::grpc::RpcMethod($Service$_method_names[$Idx$], "
+ "::grpc::RpcMethod::RpcType::SERVER_STREAMING), "
+ "context, *request, tag);\n"
+ "}\n\n");
} else if (BidiStreaming(method)) {
printer->Print(
*vars,
@@ -415,6 +448,19 @@ void PrintSourceClientMethod(google::protobuf::io::Printer *printer,
"::grpc::RpcMethod::RpcType::BIDI_STREAMING), "
"context);\n"
"}\n\n");
+ printer->Print(
+ *vars,
+ "::grpc::ClientAsyncReaderWriter< $Request$, $Response$>* "
+ "$Service$::Stub::$Method$(::grpc::ClientContext* context, "
+ "::grpc::CompletionQueue* cq, void* tag) {\n");
+ printer->Print(
+ *vars,
+ " return new ::grpc::ClientAsyncReaderWriter< $Request$, $Response$>("
+ "channel(), cq, "
+ "::grpc::RpcMethod($Service$_method_names[$Idx$], "
+ "::grpc::RpcMethod::RpcType::BIDI_STREAMING), "
+ "context, tag);\n"
+ "}\n\n");
}
}
diff --git a/src/cpp/client/client_unary_call.cc b/src/cpp/client/client_unary_call.cc
index bc0e83733a..1221630a35 100644
--- a/src/cpp/client/client_unary_call.cc
+++ b/src/cpp/client/client_unary_call.cc
@@ -60,4 +60,11 @@ Status BlockingUnaryCall(ChannelInterface *channel, const RpcMethod &method,
return status;
}
+void AsyncUnaryCall(ChannelInterface *channel, const RpcMethod &method,
+ ClientContext *context,
+ const google::protobuf::Message &request,
+ google::protobuf::Message *result, Status *status,
+ CompletionQueue *cq, void *tag) {
+
+}
} // namespace grpc