3 Getting up and running with gRPC and Golang

 

This chapter covers

  • Working with protocol buffers
  • Generating stubs from .proto files
  • Adding a stub generation process into the CI/CD pipeline using Github Actions
  • Maintaining .proto files in a separate repository
  • Maintaining backward and forward compatibility for protocol buffers

The communication between two services is just like two people talking: people use a telephone to connect, and gRPC does the same thing for interservice communication. In the same way that people use language to understand each other, two services use protocol buffers to exchange messages. It is crucial to select the proper communication style to create an effective relationship. Now that we understand that vital communication strategy, let’s see how protocol buffers and gRPC are used together in microservice communication.

3.1 Protocol buffers

3.1.1 Defining message type

3.1.2 Protocol buffer encoding

3.2 Generating stubs

3.2.1 Protocol buffer compiler installation

3.2.2 Using the protocol buffer compiler

3.3 Maintaining .proto files

3.3.1 Proto project structure

3.3.2 Automation for source code generation

3.4 Backward and forward compatibility

3.4.1 Adding new fields

3.4.2 Upgrading the server but not the client

3.4.3 Upgrading the client but not the server

3.4.4 Adding/removing oneof fields

3.4.5 Moving fields out of or into oneof fields

Summary