Table of Contents
- Examples — Month 5 (gRPC, Architecture & Microservices)
- Week 1 — wire & error model
- Week 2 — interceptors, transport & transcoding
- Week 3 — architecture, DI & caching
- Week 4 — capstone project (queue, workers, retries, metrics)
Examples — Month 5 (gRPC, Architecture & Microservices)¶
Standard-library-only programs that teach the mechanics underneath gRPC. gRPC
itself needs third-party code (google.golang.org/grpc, protoc), so the
actual client/server code lives as snippets inside the day notes; these runnable
examples rebuild the wire-level, middleware, transport, and routing concepts
with the stdlib so they compile and run with nothing installed.
Week 1 — wire & error model¶
| Topic | Run | Teaches | Day |
|---|---|---|---|
protowire |
go run ./examples/month-05/protowire |
protobuf wire format: varints, zigzag, field tags, length-delimited fields | 113 |
framing |
go run ./examples/month-05/framing |
length-prefixed message framing (gRPC's 5-byte frame) — the basis of streaming | 116-117 |
deadline |
go run ./examples/month-05/deadline |
RPC deadline/timeout propagation via context.Context, DeadlineExceeded |
118 |
statuscodes |
go run ./examples/month-05/statuscodes |
gRPC canonical status-code error model and the code→HTTP mapping | 118 |
Week 2 — interceptors, transport & transcoding¶
| Topic | Run | Teaches | Day |
|---|---|---|---|
interceptors |
go run ./examples/month-05/interceptors |
unary interceptor chain — logging + panic recovery middleware, composition order | 120 |
authmeta |
go run ./examples/month-05/authmeta |
call metadata in context, case-insensitive keys, bearer-token auth check |
121 |
tls |
go run ./examples/month-05/tls |
TLS transport: self-signed cert generation, server presentation, client trust/verification (crypto/tls) |
122 |
transcoding |
go run ./examples/month-05/transcoding |
grpc-gateway REST transcoding: path-template match, {id} extraction, JSON |
123 |
Week 3 — architecture, DI & caching¶
| Topic | Run | Teaches | Day |
|---|---|---|---|
hexagonal |
go run ./examples/month-05/hexagonal |
ports & adapters: a dependency-free core that owns its repository port, an in-memory adapter, dependencies pointing inward | 127 |
manualdi |
go run ./examples/month-05/manualdi |
manual constructor injection: inject interfaces (clock, greeter), one composition root, production vs test wiring | 128 |
domainmodel |
go run ./examples/month-05/domainmodel |
domain modeling: value objects vs entities, validating constructors, integer money, value equality, "make invalid states unrepresentable" | 130 |
cacheaside |
go run ./examples/month-05/cacheaside |
cache-aside: read-through on miss, TTL staleness bound, delete-on-write invalidation, hit/miss counters | 132 |
wire(Day 129), the Redis client (Day 132), and ADRs (Day 131) need third-party libs or are prose, so they live as snippets/notes in the day files.
Week 4 — capstone project (queue, workers, retries, metrics)¶
| Topic | Run | Teaches | Day |
|---|---|---|---|
jobqueue |
go run ./examples/month-05/jobqueue |
Redis-list-shaped background queue: buffered channel as the broker, worker pool, backpressure, graceful drain | 136 |
workerpool |
go run ./examples/month-05/workerpool |
bounded worker pool with context-driven shutdown; producer owns/closes the channel; closer goroutine ends the consumer range | 136 |
retry |
go run ./examples/month-05/retry |
exponential backoff + full jitter, max-attempt budget, permanent-vs-transient classification, dead-letter hand-off | 137 |
metrics |
go run ./examples/month-05/metrics |
Prometheus-style counter registry + text exposition format, scraped over HTTP with httptest |
138 |
Day 135 (hexagonal layering) reuses the Week 3
hexagonalandmanualdiexamples; the project-specific snippets live in the day note.
Every program imports only the standard library.