smallnest / rpcx

Best microservices framework in Go, like alibaba Dubbo, but with more features, Scale easily. Try it. Test it. If you feel it's better, use it! 𝐉𝐚𝐯𝐚有𝐝𝐮𝐛𝐛𝐨, 𝐆𝐨𝐥𝐚𝐧𝐠有𝐫𝐩𝐜𝐱! build for cloud!
https://rpcx.io
Other
8.08k stars 1.16k forks source link

是否考虑在路由时,用显示声明的handler取代反射 #843

Closed hankeyyh closed 6 months ago

hankeyyh commented 6 months ago

类似grpc,kitex会在pb中显示构建serviceInfo,其中指定了handler。内部路由时可以摆脱反射。

var Greeter_ServiceDesc = grpc.ServiceDesc{
    ServiceName: "helloworld.Greeter",
    HandlerType: (*GreeterServer)(nil),
    Methods: []grpc.MethodDesc{
        {
            MethodName: "SayHello",
            Handler:    _Greeter_SayHello_Handler,
        },
    },
smallnest commented 6 months ago

这个rpcx很早就实现了,性能上要比反射好一些

https://github.com/rpcxio/rpcx-examples/blob/master/handler/server/server.go#L14