小编gsp*_*spq的帖子

如何在 CloudRun 上通过反射来 grpcurl 列出 gRPC 服务?

按照这个例子:

\n

Google Cloud Run 中的 gRPC

\n

https://github.com/grpc-ecosystem/grpc-cloud-run-example/blob/master/golang/README.md

\n

我已经在 CloudRun 上部署了带有反射的 gRPC 服务。

\n

使用 grpcurl 进行测试:\n https://github.com/fullstorydev/grpcurl

\n
grpcurl \\\n-proto protos/calculator.proto \\\n-d \'{"first_operand": 2.0, "second_operand": 3.0, "operation": "ADD"}\' \\\n${ENDPOINT}:443 \\\nCalculator.Calculate\n
Run Code Online (Sandbox Code Playgroud)\n

GRPC 服务器反射协议\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)

go grpc google-cloud-run

6
推荐指数
1
解决办法
9492
查看次数

标签 统计

go ×1

google-cloud-run ×1

grpc ×1