grpc service based on protobuf multi-repo
Closed this issue · 1 comments
ok so we have a microservices project . each member of team has his microservice , and each microservice has a proto file .
now we have a folder in each microservice ( Gen ) and it has all the proto files and compiled protos as well . like this
yourproject/
├── gen/
│ └── user/
│ └── v1/
│ ├── user.pb.go
│ └── user_grpc.pb.go
│ └── device/
│ └── v1/
│ ├── device.pb.go
│ └── device_grpc.pb.go
├── protos/
│ └── user.proto
└── device.proto
this structure is convinient for git repo as sub module , what i want is to be able to separate proto files from the compiled protos , to be able to push and pull proto folder in repo to share with the team . we should have in settings or config somewhere to folder(path)_of_protos = "APi/protos" , folder(path)_compiled_protos="API/gen/serviceName" . this way we can always share protos folder as git repo with the team , and they can just pull the repo and "make proto" .
unless am missing something here you can guide me please , how to work with multi repos with multi microservies in a team ?! how to keep the proto files up to date as a git submodule in all of out microservices .
For microservices multi-repo, if you want to share proto files with other services, you can solve it like this:
Create a public git repository (e.g. public_proto) that stores only proto files and generated go stub code, e.g. the file directory is as follows:
·
├── gen
│ ├── user
│ │ └── v1
│ │ ├── user.pb.go
│ │ └── user_grpc.pb.go
│ └── device
│ └── v1
│ ├── device.pb.go
│ └── device_grpc.pb.go
├── protos
│ ├── user
│ │ └── user.proto
│ └── device
│ └── device.proto
├── go.mod
└── go.sum
When other microservices need to be used, just copy the directory under the directory protos
to the third_party directory under the local microservice, for example, the file directory is as follows:
·
├── api
│ └── serverName
│ └── v1
│ └── serverName.proto
│......
│
├── third_party
│ └── protos
│ ├── user
│ │ └── user.proto
│ └── device
│ └── device.proto
│......
│
├── go.mod
└── go.sum
The local microservice api/serverName/v1/serverName.proto
can import dependent public proto files.