按照这个例子:
\nGoogle Cloud Run 中的 gRPC
\nhttps://github.com/grpc-ecosystem/grpc-cloud-run-example/blob/master/golang/README.md
\n我已经在 CloudRun 上部署了带有反射的 gRPC 服务。
\n使用 grpcurl 进行测试:\n https://github.com/fullstorydev/grpcurl
\ngrpcurl \\\n-proto protos/calculator.proto \\\n-d \'{"first_operand": 2.0, "second_operand": 3.0, "operation": "ADD"}\' \\\n${ENDPOINT}:443 \\\nCalculator.Calculate\nRun Code Online (Sandbox Code Playgroud)\nGRPC 服务器反射协议\n https://github.com/grpc/grpc/blob/master/doc/server-reflection.md
\n现在我想按照这些说明使用反射。
\n--- a/examples/helloworld/greeter_server/main.go\n+++ b/examples/helloworld/greeter_server/main.go\n@@ -40,6 +40,7 @@ import (\n "google.golang.org/grpc"\n pb "google.golang.org/grpc/examples/helloworld/helloworld"\n+ "google.golang.org/grpc/reflection"\n )\n\n const (\n@@ -61,6 +62,8 @@ func main() {\n }\n s := grpc.NewServer()\n pb.RegisterGreeterService(s, &pb.GreeterService{SayHello: sayHello})\n+ // Register reflection service on gRPC server.\n+ reflection.Register(s)\n if err := s.Serve(lis); …Run Code Online (Sandbox Code Playgroud)