summaryrefslogtreecommitdiff
path: root/grpc
diff options
context:
space:
mode:
authorKapil Sharma <kapilsh@users.noreply.github.com>2018-06-27 11:57:40 -0500
committerWouter van Oortmerssen <aardappel@gmail.com>2018-06-27 09:57:40 -0700
commitea06768ad1e1522e9ecdfa9559bfb73dc3e5227c (patch)
treeb37661edc07d3c21a34fdada1b5f25f717cd067a /grpc
parent741c63052de40c72b21d704bd685dd311ea7e4a5 (diff)
downloadflatbuffers-ea06768ad1e1522e9ecdfa9559bfb73dc3e5227c.tar.gz
flatbuffers-ea06768ad1e1522e9ecdfa9559bfb73dc3e5227c.tar.bz2
flatbuffers-ea06768ad1e1522e9ecdfa9559bfb73dc3e5227c.zip
Go GRPC generator Updates - Fixes #4787 (#4797)
* Fix for #4787 - Updated the grpc generator for go to use full namespace for service rpc method names * Formatting Fix - Set to Google Style Formatting
Diffstat (limited to 'grpc')
-rw-r--r--grpc/src/compiler/go_generator.cc7
-rw-r--r--grpc/src/compiler/go_generator.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/grpc/src/compiler/go_generator.cc b/grpc/src/compiler/go_generator.cc
index 0ed10cf5..d620089a 100644
--- a/grpc/src/compiler/go_generator.cc
+++ b/grpc/src/compiler/go_generator.cc
@@ -110,7 +110,7 @@ void GenerateServerMethod(const grpc_generator::Method *method, grpc_generator::
vars["Method"] = exportName(method->name());
vars["Request"] = method->get_input_type_name();
vars["Response"] = (vars["CustomMethodIO"] == "") ? method->get_output_type_name() : vars["CustomMethodIO"];
- vars["FullMethodName"] = "/" + vars["Package"] + "." + vars["Service"] + "/" + vars["Method"];
+ vars["FullMethodName"] = "/" + vars["ServicePrefix"] + "." + vars["Service"] + "/" + vars["Method"];
vars["Handler"] = "_" + vars["Service"] + "_" + vars["Method"] + "_Handler";
if (method->NoStreaming()) {
printer->Print(vars, "func $Handler$(srv interface{}, ctx $context$.Context,\n\tdec func(interface{}) error, interceptor $grpc$.UnaryServerInterceptor) (interface{}, error) {\n");
@@ -223,7 +223,7 @@ void GenerateClientMethod(const grpc_generator::Method *method, grpc_generator::
vars["Method"] = exportName(method->name());
vars["Request"] = (vars["CustomMethodIO"] == "") ? method->get_input_type_name() : vars["CustomMethodIO"];
vars["Response"] = method->get_output_type_name();
- vars["FullMethodName"] = "/" + vars["Package"] + "." + vars["Service"] + "/" + vars["Method"];
+ vars["FullMethodName"] = "/" + vars["ServicePrefix"] + "." + vars["Service"] + "/" + vars["Method"];
if (method->NoStreaming()) {
printer->Print(vars, "out := new($Response$)\n");
printer->Print(vars, "err := $grpc$.Invoke(ctx, \"$FullMethodName$\", in, out, c.cc, opts...)\n");
@@ -374,7 +374,7 @@ void GenerateService(const grpc_generator::Service *service, grpc_generator::Pri
//Service Descriptor
printer->Print(vars, "var $ServiceDesc$ = $grpc$.ServiceDesc{\n");
printer->Indent();
- printer->Print(vars, "ServiceName: \"$Package$.$Service$\",\n");
+ printer->Print(vars, "ServiceName: \"$ServicePrefix$.$Service$\",\n");
printer->Print(vars, "HandlerType: (*$Service$Server)(nil),\n");
printer->Print(vars, "Methods: []$grpc$.MethodDesc{\n");
printer->Indent();
@@ -433,6 +433,7 @@ grpc::string GenerateServiceSource(grpc_generator::File *file,
auto printer = p.get();
std::map<grpc::string, grpc::string> vars;
vars["Package"] = parameters->package_name;
+ vars["ServicePrefix"] = parameters->service_prefix;
vars["grpc"] = "grpc";
vars["context"] = "context";
GenerateImports(file, printer, vars);
diff --git a/grpc/src/compiler/go_generator.h b/grpc/src/compiler/go_generator.h
index e377024a..baa94e05 100644
--- a/grpc/src/compiler/go_generator.h
+++ b/grpc/src/compiler/go_generator.h
@@ -49,6 +49,9 @@ struct Parameters {
//Package name for the service
grpc::string package_name;
+
+ //Prefix for RPC Calls
+ grpc::string service_prefix;
};
// Return the source of the generated service file.