project-layout icon indicating copy to clipboard operation
project-layout copied to clipboard

gRPC ant proto declarations?

Open danf0rth opened this issue 6 years ago • 4 comments

What is a common approach when project is using a protobuf and gRPC?

  • Where to keep *.proto files?
  • Where should be generated files placed, near to protobuf declarations or in another place?
  • Any other tips to build clean folder layout when using protobuf and grpc?

Thanks to everyone!

danf0rth avatar Mar 28 '19 15:03 danf0rth

*.proto files accordingly to these recommendations should be stored in /api/proto/v1/*.proto. As well generated swagger files in /api/swagger/v1/*.swagger.json.

oswee avatar Jun 03 '19 13:06 oswee

And what's about generated *.pb.go files?

atipugin avatar Jun 13 '19 13:06 atipugin

I am not an expert, so... but i am generating them into /pkg/api/v1. I have protoc-gen.sh file with content like this:

protoc --proto_path=api/proto/v1 --proto_path=third_party --go_out=plugins=grpc:pkg/api/v1 auth_service.proto
protoc --proto_path=api/proto/v1 --proto_path=third_party --grpc-gateway_out=logtostderr=true:pkg/api/v1 auth_service.proto
protoc --proto_path=api/proto/v1 --proto_path=third_party --swagger_out=logtostderr=true:api/swagger/v1 auth_service.proto

It should be executable - chmod +x protoc-gen.sh Simply run it by ./scripts/protoc-gen.sh from projects root directory.

third_party in my case contains protobuf annotations, etc.

oswee avatar Jun 14 '19 14:06 oswee

whoever was "ghost", you helped a lot buddy.

rubens21 avatar Aug 29 '20 16:08 rubens21