为了账号安全,请及时绑定邮箱和手机立即绑定

如何在 CloudRun 上反映 gRPC 服务的列表?

如何在 CloudRun 上反映 gRPC 服务的列表?

Go
慕尼黑8549860 2022-08-15 15:46:16
按照此示例执行以下操作:gRPC in Google Cloud Runhttps://github.com/grpc-ecosystem/grpc-cloud-run-example/blob/master/golang/README.md我已经部署了一个gRPC服务,并在CloudRun上进行了反思。使用 grpcurl 进行测试:https://github.com/fullstorydev/grpcurlgrpcurl \-proto protos/calculator.proto \-d '{"first_operand": 2.0, "second_operand": 3.0, "operation": "ADD"}' \${ENDPOINT}:443 \Calculator.CalculateGRPC 服务器反射协议 https://github.com/grpc/grpc/blob/master/doc/server-reflection.md现在我想按照这些说明使用反射。--- a/examples/helloworld/greeter_server/main.go+++ b/examples/helloworld/greeter_server/main.go@@ -40,6 +40,7 @@ import (        "google.golang.org/grpc"        pb "google.golang.org/grpc/examples/helloworld/helloworld"+       "google.golang.org/grpc/reflection" ) const (@@ -61,6 +62,8 @@ func main() {        }        s := grpc.NewServer()        pb.RegisterGreeterService(s, &pb.GreeterService{SayHello: sayHello})+       // Register reflection service on gRPC server.+       reflection.Register(s)        if err := s.Serve(lis); err != nil {                log.Fatalf("failed to serve: %v", err)        }https://github.com/grpc/grpc-go/blob/master/Documentation/server-reflection-tutorial.md#enable-server-reflection您尝试了什么:本地测试。请注意:grpcurl -plaintext 表示不是 TLS。省略 -纯文本表示 TLS。什么有效:############################# local testing############################request list:grpcurl -plaintext localhost:8080 listresult:Calculatorgrpc.reflection.v1alpha.ServerReflectionrequest ADD function:grpcurl -plaintext \    -d '{"first_operand": 2.0, "second_operand": 3.0, "operation": "ADD"}' \    localhost:8080 \    Calculator.Calculateresult:{  "result": 5}############################您尝试的内容:GCP CloudRun 测试。请注意:grpcurl -plaintext 表示不是 TLS。省略 -纯文本表示 TLS。什么有效:request:grpcurl \    -proto protos/calculator.proto \    -d '{"first_operand": 2.0, "second_operand": 3.0, "operation": "ADD"}' \    ${ENDPOINT}:443 \    Calculator.Calculateresult:{  "result": 5}什么不起作用:我想使用反射,所以省略:-proto protos/calculator.proto \我想使用TLS,所以省略了:-plaintext
查看完整描述

1 回答

?
哆啦的时光机

TA贡献1779条经验 获得超6个赞

gRPC 反射需要双向流式处理,因此请确保在部署时选中启用 HTTP/2 选项 (--use-http2)。这将实现双迪流。

此外,请确保使用 :443 端口,并在需要时通过添加身份验证元数据向服务器进行身份验证(请参阅服务到服务身份验证文档)。


查看完整回答
反对 回复 2022-08-15
  • 1 回答
  • 0 关注
  • 76 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信