* This post is the second in the series about gRPC
When developing a gRPC application the first thing you do is define a service interface. The service interface definition contains information about how your service can be consumed by consumers, what methods it allows consumers to call remotely, what method parameters and message formats to use when invoking those methods, etc. The language in which we specify the service definition is known as Interface Definition Language (IDL) and in gRPC Protocol Buffers is used. In addition, HTTP/2 is used to transport the information.
Using Protocol Buffers, you can generate server-side code known as server skeleton, which simplifies the server-side logic by providing low-level communication abstractions. You can also generate client-side code, known as client stub, which simplifies client-side communication with abstractions to hide low-level communication for different programming languages. Methods that are specified in the service interface definition can be invoked remotely by the client side as easily as if it were a local function invocation. gRPC handles all the complexities normally associated with enforcing strict service contracts, data serialization, network communication, authentication, access control, observability, etc.
Let me show you an example to give you a better understanding of how gRPC works. Imagine you are building a beverage ecommerce, composed of several microservices. You want one of them to provide the details of the drinks that are available in your app. The DrinkInfo service is modeled in such a way that it is exposed across the network as a gRPC service.
The service definition is specified in the DrinkInfo.proto file, which is used by both the server and client side to generate the code. In this example, I have assumed that the consumer is implemented using Node and the server is implemented using Python. Network communication between the service and the consumer takes place over HTTP/2.
In the next post I will delve into the details of this gRPC communication.
I take this opportunity to recommend some books that may interest you: