3 Getting up and running with gRPC and Golang

 

This chapter covers

  • Internals of working with Protocol Buffers
  • Generating stubs from proto files
  • Adding stub generation process into CI/CD pipeline by using Github Actions
  • Maintaining proto files in a separate repository
  • Maintaining backward and forward compatibility for Protocol Buffers

The communication of two services is just like two people talking. For example, those people use a telephone to connect them, like gRPC, for inter-service communication. In the same way, people use language to understand each other, just like two services use Protocol Buffers to exchange their messages. It is crucial to select a proper communication style for an effective relationship. Now that we understand the 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 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 Server, But Not Client

3.4.3 Upgrading Client, But Not Server

3.4.4 Adding / Removing 'oneof' Fields

3.4.5 Moving Fields Out of or Into a `oneof`

3.5 Summary