按照此示例執(zhí)行以下操作:gRPC in Google Cloud Runhttps://github.com/grpc-ecosystem/grpc-cloud-run-example/blob/master/golang/README.md我已經(jīng)部署了一個gRPC服務(wù),并在CloudRun上進(jìn)行了反思。使用 grpcurl 進(jìn)行測試:https://github.com/fullstorydev/grpcurlgrpcurl \-proto protos/calculator.proto \-d '{"first_operand": 2.0, "second_operand": 3.0, "operation": "ADD"}' \${ENDPOINT}:443 \Calculator.CalculateGRPC 服務(wù)器反射協(xié)議 https://github.com/grpc/grpc/blob/master/doc/server-reflection.md現(xiàn)在我想按照這些說明使用反射。--- 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}############################您嘗試的內(nèi)容: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
如何在 CloudRun 上反映 gRPC 服務(wù)的列表?
慕尼黑8549860
2022-08-15 15:46:16