I plan to use grpc as an inter-service sync communication protocol.
There are lots of different services and I have generated a pb.go file with all the relevant code for client and server using protoc with the go-rpc plugin.
Now I'm trying to figure out the best way or the common way of consuming this service from another service. Here is what I have so far:
Option 1
- use the
.protofile from the service (download it) - run the
protoccompiler and generate the...pb.gofile for the consumer to use
Option 2
- because the
...pb.gois already generated on the grpc service side to implement the server and my client is another service written in go I can expose this as a sub module (another.modfile in a sub- directory) - use
go get github.com/usr/my-cool-grpc-service/client
Option 2 seems more appealing to me because it makes the consumption of a service very easy and available for all other services that may require it.
On the other hand I know that the .proto file is the contract that cann generate clients for many different languages and should be used the the source of truth.
I fear that by choosing option 2 I'm unaware of any possible pitfalls I might encounter with regards to backwards compatibility or any other topic..
So, what is the idiomatic way of consuming a gRPC service?