consuming grpc service using go

Viewed 104

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

  1. use the .proto file from the service (download it)
  2. run the protoc compiler and generate the ...pb.go file for the consumer to use

Option 2

  1. because the ...pb.go is 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 .mod file in a sub- directory)
  2. 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?

0 Answers
Related