Skip to content
Ameen Abozaid
Planned lessonMID-024-L04

gRPC and Protocol Buffers

  • Lesson 4 of 6
  • Mid-level
On This Lesson 4 topics

This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.

In this lesson

define a service in .proto and understand the call types.

Planned topics

  • A .proto file defines messages (typed, numbered fields) and services (methods).
  • Field numbers identify fields on the wire; never reuse or renumber them. Adding fields is backward compatible.
  • Four call types: unary, server streaming, client streaming, bidirectional streaming.
  • Set a deadline on every client call; deadlines propagate and replace ad-hoc timeouts.
  • In Spring, use a gRPC starter such as Spring gRPC or grpc-spring-boot-starter (verify the current choice and version before recording).
Draft outline details

Demonstration

proto
syntax = "proto3";
service InventoryService {
  rpc CheckStock (StockRequest) returns (StockReply);
}
message StockRequest { string sku = 1; int32 quantity = 2; }
message StockReply   { bool available = 1; int32 on_hand = 2; }

Check your understanding

Why never renumber a proto field?

Show answer

Existing clients identify fields by number and would misread data.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.