From cdc253535bb879918b9bd66b29007f27219f6e2e Mon Sep 17 00:00:00 2001
From: Vijay Pai <vpai@google.com>
Date: Thu, 25 Aug 2016 15:33:02 -0700
Subject: [PATCH] Remove FC_UNARY enum and treat it more like a special case of
 BIDI_STREAMING in all cases

---
 include/grpc++/impl/codegen/rpc_method.h   | 3 +--
 include/grpc++/impl/codegen/service_type.h | 5 ++++-
 src/compiler/cpp_generator.cc              | 2 +-
 src/cpp/server/server.cc                   | 1 -
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/include/grpc++/impl/codegen/rpc_method.h b/include/grpc++/impl/codegen/rpc_method.h
index b55d755075..4897428074 100644
--- a/include/grpc++/impl/codegen/rpc_method.h
+++ b/include/grpc++/impl/codegen/rpc_method.h
@@ -46,8 +46,7 @@ class RpcMethod {
     NORMAL_RPC = 0,
     CLIENT_STREAMING,  // request streaming
     SERVER_STREAMING,  // response streaming
-    BIDI_STREAMING,
-    FC_UNARY  // flow-controlled unary call
+    BIDI_STREAMING
   };
 
   RpcMethod(const char* name, RpcType type)
diff --git a/include/grpc++/impl/codegen/service_type.h b/include/grpc++/impl/codegen/service_type.h
index dcfc6b01b7..4af40422a1 100644
--- a/include/grpc++/impl/codegen/service_type.h
+++ b/include/grpc++/impl/codegen/service_type.h
@@ -150,8 +150,11 @@ class Service {
   void MarkMethodFCUnary(int index, MethodHandler* fc_unary_method) {
     GPR_CODEGEN_ASSERT(methods_[index] && methods_[index]->handler() &&
                        "Cannot mark an async or generic method as FCUnary");
-    methods_[index]->SetMethodType(::grpc::RpcMethod::FC_UNARY);
     methods_[index]->SetHandler(fc_unary_method);
+
+    // From the server's point of view, streamed unary is a special
+    // case of BIDI_STREAMING that has 1 read and 1 write, in that order.
+    methods_[index]->SetMethodType(::grpc::RpcMethod::BIDI_STREAMING);
   }
 
  private:
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index 252a92d971..c5d4c2573d 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -1154,7 +1154,7 @@ void PrintSourceService(Printer *printer, const Service *service,
     (*vars)["Idx"] = as_string(i);
     if (method->NoStreaming()) {
       (*vars)["StreamingType"] = "NORMAL_RPC";
-      // NOTE: There is no reason to consider FC_UNARY as a separate
+      // NOTE: There is no reason to consider streamed-unary as a separate
       // category here since this part is setting up the client-side stub
       // and this appears as a NORMAL_RPC from the client-side.
     } else if (method->ClientOnlyStreaming()) {
diff --git a/src/cpp/server/server.cc b/src/cpp/server/server.cc
index c1fbaa09f5..af04fd4ca6 100644
--- a/src/cpp/server/server.cc
+++ b/src/cpp/server/server.cc
@@ -342,7 +342,6 @@ static grpc_server_register_method_payload_handling PayloadHandlingForMethod(
       return GRPC_SRM_PAYLOAD_READ_INITIAL_BYTE_BUFFER;
     case RpcMethod::CLIENT_STREAMING:
     case RpcMethod::BIDI_STREAMING:
-    case RpcMethod::FC_UNARY:
       return GRPC_SRM_PAYLOAD_NONE;
   }
   GPR_UNREACHABLE_CODE(return GRPC_SRM_PAYLOAD_NONE;);
-- 
GitLab