Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import gRPC empty and Google api annotations proto

I am trying to use Google Cloud Endpoints to make a gRPC based api that can transcode incoming REST requests. I am following their example code but I can not any documentation on how to properly import and compile with the annotation.proto or the empty.proto.

Thank you!

like image 628
Arjun Yelamanchili Avatar asked Apr 09 '17 23:04

Arjun Yelamanchili


3 Answers

I didn't understand that this was part of grpc-gateway. By following the docs I ran

protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=plugins=grpc:. *.proto

and compiled successfully.

like image 159
Arjun Yelamanchili Avatar answered Oct 21 '22 10:10

Arjun Yelamanchili


The empty.proto and annotation.proto are not included by default, so you'll need to bring in a copy. Specifically you can make a copy of them in a directory in your project, or reference them in an existing project (like the Protobuf git repo, for instance).

It is probably a good idea to NOT reference the copy that grpc-ecosystem/grpc-gateway uses, because they may want to move it around in the future.

like image 5
Carl Mastrangelo Avatar answered Oct 21 '22 08:10

Carl Mastrangelo


it may not be a good idea. you can copy google/api/annotations.proto and google/api/http.proto into your local project and import them when run python -m

mkdir -p google/api    
curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/annotations.proto > google/api/annotations.proto     
curl https://raw.githubusercontent.com/googleapis/googleapis/master/google/api/http.proto > google/api/http.proto

python -m grpc_tools.protoc google/api/http.proto google/api/annotations.proto -I. --python_out=. --grpc_python_out=. your_proto.proto

refurl: https://cloud.google.com/solutions/exposing-grpc-services-using-cloud-endpoints-pt1

like image 8
gaozhidf Avatar answered Oct 21 '22 08:10

gaozhidf