Monday, 17 June 2019

How to communicate between gRPC micro-services in Go-Lang

Hi Everybody,
Today we will see how to build gRPC based micro-services from scratch and how to communicate with each other.
In this example we will be writing two gRPC micro-services and RPC2 will communicate to RPC1 and vicer-versa can be extended later. gRPC requires at-least the basic knowledge of Protobuf, In order to deep dive into this example I suggest you to go through the basics of protobuf and gRPC here (in case if you are new to gRPC): https://grpc.io/docs/guides/

Now all set let us create our first micro-service in Go Lang and call it grpc_comm_1.go


Similarly let's create the second gRPC and call it grpc_comm_2.go


Now both services are ready first run the service grpc_comm_1.go and then following that run grpc_comm_2.go and in the terminal you can see the output displaying the services interacting with each other.

I have hosted the complete source code in git: https://github.com/harishp8889/haritechtalk/tree/master/go-lang/GRPC 
clone the GRPC folder which has all the code explained in the above example along with a gRPC client for testing purpose.

No comments:

Post a Comment