aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar James Eady <jmeady@google.com>2017-05-02 10:45:34 -0400
committerGravatar James Eady <jmeady@google.com>2017-05-02 10:45:34 -0400
commit3b26451025118b1f2764dcc618cb3a5fd8abdd4b (patch)
tree5d9e6ae8c142f45f914cc828d21c01949dacffd4
parent305dcf3d32bed0614325ead76f121702768ce874 (diff)
Add static method to generated code to return fully qualified protobuf service name.
-rw-r--r--src/compiler/cpp_generator.cc7
-rw-r--r--test/cpp/codegen/compiler_test_golden6
2 files changed, 13 insertions, 0 deletions
diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc
index d3e71625d6..bbf17314e9 100644
--- a/src/compiler/cpp_generator.cc
+++ b/src/compiler/cpp_generator.cc
@@ -804,6 +804,13 @@ void PrintHeaderService(grpc_generator::Printer *printer,
" public:\n");
printer->Indent();
+ // Service metadata
+ printer->Print(
+ *vars,
+ "static constexpr char const* service_full_name() {\n"
+ " return \"$Package$$Service$\";\n"
+ "}\n");
+
// Client side
printer->Print(
"class StubInterface {\n"
diff --git a/test/cpp/codegen/compiler_test_golden b/test/cpp/codegen/compiler_test_golden
index 8e3ae32a49..eb12d371ea 100644
--- a/test/cpp/codegen/compiler_test_golden
+++ b/test/cpp/codegen/compiler_test_golden
@@ -69,6 +69,9 @@ namespace testing {
// ServiceA leading comment 1
class ServiceA final {
public:
+ static constexpr char const* service_full_name() {
+ return "grpc.testing.ServiceA";
+ }
class StubInterface {
public:
virtual ~StubInterface() {}
@@ -373,6 +376,9 @@ class ServiceA final {
// ServiceB leading comment 1
class ServiceB final {
public:
+ static constexpr char const* service_full_name() {
+ return "grpc.testing.ServiceB";
+ }
class StubInterface {
public:
virtual ~StubInterface() {}