gRPC and ASP.NET Core: serverside reflection

北战南征 提交于 2019-12-25 01:12:00

问题


I've been trying to implement the concepts of serverside reflection described in https://github.com/grpc/grpc/blob/master/doc/server-reflection.md and for C# https://github.com/grpc/grpc/blob/master/doc/csharp/server_reflection.md in the implementation of ASP.NET Core. You have to somehow configure Kestrel to enable Reflection first. I just don't succeed and have to give up. This is the tricky part that somehow has to be implemented in ASP.NET Core.

// the reflection service will be aware of "Greeter" and "ServerReflection" services. var reflectionServiceImpl = new ReflectionServiceImpl(Greeter.Descriptor, ServerReflection.Descriptor);

server = new Server()
{
    Services =
    {
        // the server will serve 2 services, the Greeter and the ServerReflection
        ServerReflection.BindService(new GreeterImpl()),
        ServerReflection.BindService(reflectionServiceImpl)
    },
    Ports = { { "localhost", 50051, ServerCredentials.Insecure } }
};
server.Start();

Does somebody know how to enable serverside reflection in ASP.NET Core with Kestrel? Or even better has a complete working example of serverside reflection in C# ASP.NET Core?

Update

It seems that the default implementation of .NET Core 3.1 doesn't support the reflection yet. The NuGet https://github.com/grpc/grpc-dotnet/ does work and seamlessly integrates in ASP.NET Core. The example covers discovering services on a server. I can't find concrete descriptions how to iterate through all methods on a service and all fields in a message. Maybe JamesNK can help?

来源:https://stackoverflow.com/questions/59335078/grpc-and-asp-net-core-serverside-reflection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!