Project 9: gRPC Service with Streaming

A microservices system using gRPC with all four communication patterns: unary, server streaming, client streaming, and bidirectional streaming—implementing a real-time chat service.

Quick Reference

Attribute Value
Primary Language Go
Alternative Languages Java, C++, Python
Difficulty Level 3: Advanced
Time Estimate 2 weeks
Knowledge Area RPC, Protocol Buffers, Microservices
Tooling grpc-go, protoc
Prerequisites Completed Projects 1-6. Basic understanding of RPC. Familiarity with protocol buffers is helpful.

What You Will Build

A microservices system using gRPC with all four communication patterns: unary, server streaming, client streaming, and bidirectional streaming—implementing a real-time chat service.

Why It Matters

This project builds core skills that appear repeatedly in real-world systems and tooling.

Core Challenges

  • Defining Protocol Buffers → maps to schema design and code generation
  • Implementing streaming RPCs → maps to concurrent streams and flow control
  • gRPC interceptors → maps to middleware and cross-cutting concerns
  • Error handling in gRPC → maps to status codes and error details

Key Concepts

  • Protocol Buffers: protobuf.dev documentation
  • gRPC patterns: “gRPC: Up and Running” - Kasun Indrasiri
  • Streaming: “gRPC: Up and Running” Ch. 4 - Kasun Indrasiri
  • Interceptors: gRPC documentation on middleware

Real-World Outcome

// chat.proto
syntax = "proto3";

service ChatService {
  // Unary: send single message
  rpc SendMessage(Message) returns (SendResponse);

  // Server streaming: get message history
  rpc GetHistory(HistoryRequest) returns (stream Message);

  // Client streaming: upload file in chunks
  rpc UploadFile(stream FileChunk) returns (UploadResponse);

  // Bidirectional: real-time chat
  rpc Chat(stream Message) returns (stream Message);
}

Implementation Guide

  1. Reproduce the simplest happy-path scenario.
  2. Build the smallest working version of the core feature.
  3. Add input validation and error handling.
  4. Add instrumentation/logging to confirm behavior.
  5. Refactor into clean modules with tests.

Milestones

  • Milestone 1: Minimal working program that runs end-to-end.
  • Milestone 2: Correct outputs for typical inputs.
  • Milestone 3: Robust handling of edge cases.
  • Milestone 4: Clean structure and documented usage.

Validation Checklist

  • Output matches the real-world outcome example
  • Handles invalid inputs safely
  • Provides clear errors and exit codes
  • Repeatable results across runs

References

  • Main guide: LEARN_GO_DEEP_DIVE.md
  • “gRPC: Up and Running” by Kasun Indrasiri