无法使 grpc-gateway .gw.pb 并且没有错误
Cannot make grpc-gateway .gw.pb and there is no error
我已经编写了这个简单的 go 服务器和客户端,客户端发送两个数字,服务器回复总和,它可以工作。现在我正在尝试使用 grpc API 配置设置 grpc-gateway 并将客户端的请求从 GRPC 更改为 rest.
我正在使用这个 tutorial 并且在下面的部分中,我无法创建 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
。
我在 Gophers slack 的 grpc-channel 中问了这个问题,Johan Brandhorst 帮助了我。
我已经编写了这个简单的 go 服务器和客户端,客户端发送两个数字,服务器回复总和,它可以工作。现在我正在尝试使用 grpc API 配置设置 grpc-gateway 并将客户端的请求从 GRPC 更改为 rest.
我正在使用这个 tutorial 并且在下面的部分中,我无法创建 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
。
我在 Gophers slack 的 grpc-channel 中问了这个问题,Johan Brandhorst 帮助了我。