当前位置: > > > > 无法制作 grpc-gateway.gw.pb 并且没有错误
来源:stackoverflow
2024-04-20 08:15:39
0浏览
收藏
Golang不知道大家是否熟悉?今天我将给大家介绍《无法制作 grpc-gateway.gw.pb 并且没有错误》,这篇文章主要会讲到等等知识点,如果你在看完本篇文章后,有更好的建议或者发现哪里有问题,希望大家都能积极评论指出,谢谢!希望我们能一起加油进步!
问题内容
我编写了这个简单的 go 服务器和客户端,客户端发送两个数字,服务器回复总和,并且它可以工作。现在我尝试使用 grpc api 配置来设置 grpc-gateway 并将客户端的请求从 grpc 更改为休息。
我正在使用本教程,在下面的部分中,我无法创建 gw,但没有错误:
protoc -i/usr/local/include -i. \ -i$gopath/src \ -i$gopath/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ --grpc-gateway_out=logtostderr=true,grpc_api_configuration=path/to/your_service.yaml:. \ path/to/your_service.proto
我用的是这个:
protoc -i/usr/local/include -i. -i$gopath/src -i$gopath/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true,grpc_api_configuration=$gopath/src/grpc-test/sum.yaml:. ./sum.proto
在这个问题之后,我进行了搜索,发现了这种方式,但它不起作用(没有错误,也没有输出!):
protoc -i/usr/local/include -i. -i$gopath/src -i$gopath/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --plugin=protoc-gen-grpc-gateway=$gopath/bin/protoc-gen-grpc-gateway --grpc-gateway_out=logtostderr=true,grpc_api_configuration=sum.yaml:. ./sum.proto
我在 grpc-test 目录中运行它,该目录具有以下树:
那么,我做错了什么?
编辑: 这是我的 sum.yaml:
type: google.api.service config_version: 3 http: rules: - selector: example.yourservice.echo post: /v1/example/echo body: "*"
这是 sum.proto:
syntax = "proto3"; service ComputeSum { rpc ComputeSum (SumRequest) returns (ResultReply) { } } message SumRequest { int32 firstOperand = 1; int32 secondOperand = 2; } message ResultReply { int32 result = 1; }
解决方案
问题出在选择器上,它应该是ComputeSum.ComputeSum
。 我在 grpc-channel 中提出了这个问题,Johan Brandhorst 帮助了我。
本篇关于《无法制作 grpc-gateway.gw.pb 并且没有错误》的介绍就到此结束啦,但是学无止境,想要了解学习更多关于Golang的相关知识,请关注公众号!