aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2016-08-04 11:07:50 -0700
committerGravatar Vijay Pai <vpai@google.com>2016-08-04 11:07:50 -0700
commitff91dea14999225e5f6c9bcf565f28ee3acce6dd (patch)
tree222bcffb737cc6232bf15e8ae88f12f03f2b0014
parent581097fe0dc321a31cedae97057838fa1eadf8b2 (diff)
Be able to specify FCUnaryService just like AsyncService so that all
relevant methods get treated this way.
-rw-r--r--src/compiler/cpp_generator.cc16
-rw-r--r--test/cpp/end2end/hybrid_end2end_test.cc34
2 files changed, 50 insertions, 0 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index d587023c65..29007b5e1d 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -826,6 +826,22 @@ void PrintHeaderService(Printer *printer, const Service *service,
PrintHeaderServerMethodFCUnary(printer, service->method(i).get(), vars);
}
+ printer->Print("typedef ");
+ for (int i = 0; i < service->method_count(); ++i) {
+ (*vars)["method_name"] = service->method(i).get()->name();
+ if (service->method(i)->NoStreaming()) {
+ printer->Print(*vars, "WithFCUnaryMethod_$method_name$<");
+ }
+ }
+ printer->Print("Service");
+ for (int i = 0; i < service->method_count(); ++i) {
+ if (service->method(i)->NoStreaming()) {
+ printer->Print(" >");
+ }
+ }
+ printer->Print(" FCUnaryService;\n");
+
+
printer->Outdent();
printer->Print("};\n");
printer->Print(service->GetTrailingComments().c_str());
diff --git a/test/cpp/end2end/hybrid_end2end_test.cc b/test/cpp/end2end/hybrid_end2end_test.cc
index b80010e803..a1a964a9d3 100644
--- a/test/cpp/end2end/hybrid_end2end_test.cc
+++ b/test/cpp/end2end/hybrid_end2end_test.cc
@@ -454,6 +454,40 @@ TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFCUnaryDupService
request_stream_handler_thread.join();
}
+// Add a second service that is fully FCUnary
+class FullyFCUnaryDupPkg : public duplicate::EchoTestService::FCUnaryService {
+public:
+ Status FCEcho(ServerContext* context, FCUnary<EchoRequest,EchoResponse>* fc_unary) GRPC_OVERRIDE {
+ EchoRequest req;
+ EchoResponse resp;
+ uint32_t next_msg_sz;
+ fc_unary->NextMessageSize(&next_msg_sz);
+ gpr_log(GPR_INFO, "FC Unary Next Message Size is %u", next_msg_sz);
+ GPR_ASSERT(fc_unary->Read(&req));
+ resp.set_message(req.message() + "_dup");
+ GPR_ASSERT(fc_unary->Write(resp));
+ return Status::OK;
+ }
+};
+
+TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_SyncFullyFCUnaryDupService) {
+ typedef EchoTestService::WithAsyncMethod_RequestStream<
+ EchoTestService::WithAsyncMethod_ResponseStream<TestServiceImpl>>
+ SType;
+ SType service;
+ FullyFCUnaryDupPkg dup_service;
+ SetUpServer(&service, &dup_service, nullptr, 8192);
+ ResetStub();
+ std::thread response_stream_handler_thread(HandleServerStreaming<SType>,
+ &service, cqs_[0].get());
+ std::thread request_stream_handler_thread(HandleClientStreaming<SType>,
+ &service, cqs_[1].get());
+ TestAllMethods();
+ SendEchoToDupService();
+ response_stream_handler_thread.join();
+ request_stream_handler_thread.join();
+}
+
// Add a second service with one async method.
TEST_F(HybridEnd2endTest, AsyncRequestStreamResponseStream_AsyncDupService) {
typedef EchoTestService::WithAsyncMethod_RequestStream<