I have a proto3 gRPC service with these methods:
syntax = "proto3";
Service MyService
{
rpc Foo (FooRequest) returns (FooResponse) {}
rpc Bar (BarRequest) returns (BarResponse) {}
// etc.
}
I would like to access these methods dynamically in my C++ application, e.g.
google::protobuf::ServiceDescriptor serviceDescriptor;
google::protobuf::MethodDescriptor* myMethod = serviceDescriptor.FindMethodByName("Foo");
It is trivial to get a message descriptor using google::protobuf::MessageDescriptor = myMessage.GetDescriptor();
, but there doesn't seem to be an equivalent method for a service.
How do I get a ServiceDescriptor
for a Service in C++?
My instinct is that getting the ServiceDescriptor
is required to get the list of gRPC methods, but if there is another way of accomplishing this I would also be interested.