AdBlock Detected

It looks like you're using an ad-blocker!

Our team work realy hard to produce quality content on this website and we noticed you have ad-blocking enabled. Advertisements and advertising enable us to continue working and provide high-quality content.

what is gRPC

What is gRPC? Google created gRPC as an RPC (Remote Procedure Call) protocol that enables connections and calls between microservices in any environment. It serves as an alternative to REST, WebHook, or GraphQL.

  • Its main features include bidirectional streaming and fully integrated connectable authentication with HTTP/2-based transport.
  • Key highlights: high performance with low CPU and bandwidth consumption, JSON encoding, and serialization with PROTO 3.
  • It automatically generates idiomatic client and server stubs for services in various languages and platforms.
  • It supports built-in authentication with SSL.

Main Components of gRPC

In the diagram shown, you can see the flow involved in using gRPC, which will be detailed below.

Protocol Buffers or Protobuf

Google developed Protocol Buffers (protobuf) as a language-independent implementation.

The goal when creating a protobuf is to achieve a Contract First approach, defining the contract first.

The client and microservice configure communication using the Interface Definition Language (IDL) of protobuf, enabling them to create service interfaces, methods, and messages. Developers implement protobuf using a .proto file extension, which humans can easily read.

Thinking API First is essential because making changes to the .proto file after implementation can have consequences on both the client and the consuming service, requiring significant effort.

Proto Compiler

The Proto Compiler (protoc) compiles protobuf files into the desired language, making gRPC multi-language and cross-platform.

Implementation

Understanding the above points about protobuf and the proto compiler, we can proceed with the implementation and code development.

The client and server use Proto Requests and Proto Responses for communication, defining specific types for making requests and receiving responses from the service.

Conclusion

In this post, we provided a brief overview of gRPC and its basic components. In future posts, we will explore its usage and development through an example in a Spring Boot application.

If you need more information, you can leave us a comment or send an email to refactorizando.web@gmail.com You can also contact us through our social media channels on Facebook or twitter and we will be happy to assist you!!

Leave a Reply

Your email address will not be published. Required fields are marked *