diff --git a/src/compiler/cpp_generator.cc b/src/compiler/cpp_generator.cc index d3e71625d6556a2167804335f554d1326a762e57..bbf17314e99b749c18e58c1110e914683e0f994c 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 8e3ae32a4946a7785fe17d586ff2bf481cf151c1..eb12d371eaf456215c270f8861ebf00d8dafa71d 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() {}