ข้ามไปยังเนื้อหา

gRPC Design — From Zero to Hero

คอร์สแบบ standalone ตั้งแต่ผู้เริ่มต้นจนถึงขั้นสูง ว่าด้วยการออกแบบ API ด้วย gRPC และ Protocol Buffers ตั้งแต่ RPC model และ protobuf schema ไปจนถึง streaming, deadline, interceptor, load balancing, security และ gRPC-Web — ทุกหัวข้อมี .proto contract คู่กับตัวอย่าง Go, Python และ Node

gRPC Foundations

gRPC คืออะไร, RPC model, ทำไมต้องทำงานบน HTTP/2 และเทียบกับ REST อย่างไร เริ่ม →

Protocol Buffers

message และ field number, scalar type, enum, oneof, map, well-known type และการ evolve schema อย่างปลอดภัย ออกแบบ schema →

Service Definition

การนิยาม service, RPC ทั้ง 4 แบบ, การออกแบบ method signature และ error/status model ออกแบบ →

Building Services

code generation ด้วย protoc, การ implement server, การเขียน client, deadline และ cancellation สร้าง →

Streaming

server, client และ bidirectional streaming — พร้อม flow control ที่ทำให้ stream ทำงานได้ราบรื่น สตรีม →

Ecosystem & Advanced

gRPC-Web บน browser, REST/JSON transcoding, versioning ในระดับ scale, observability และ testing ต่อยอด →

Contract-first เสมอ

ทุกบทเรียนเริ่มจาก .proto — contract ที่เป็นกลางไม่ผูกกับภาษา — แล้วค่อยแสดง server และ client ที่ generate ออกมา เพื่อให้เห็นว่า schema ขับเคลื่อน code อย่างไร

สามภาษาเทียบกันชัด ๆ

ตัวอย่าง server และ client ใน Go, Python และ Node (TypeScript) ผ่านแท็บที่ sync กัน เลือกภาษาครั้งเดียวแล้วตามไปทุกที่

เน้นการออกแบบ ไม่ใช่แค่ syntax

ทุกหัวข้อครอบคลุมเหตุผลและ trade-off — เมื่อไรควร stream, ตั้ง deadline อย่างไร, evolve schema อย่างไรโดยไม่ทำให้ client พัง

ไดอะแกรมที่อธิบายได้

RPC lifecycle, HTTP/2 multiplexing, call ทั้ง 4 แบบ และ interceptor chain เป็นไดอะแกรม Mermaid ที่รองรับธีม สองภาษา (English / ไทย) พร้อมบันทึกความคืบหน้า quiz

ข้อเท็จจริง, CLI flag และรูปแบบ generated code ในคอร์สนี้ตรวจกับเครื่องมือและเอกสารทางการปัจจุบัน ณ วันที่ 2026-09-24: buf CLI 1.71 (buf.yaml/buf.gen.yaml ใช้ version: v2, remote plugin บน BSR), protoc 33.x, Go 1.26 คู่กับ google.golang.org/grpc (grpc.NewClient — grpc.Dial ถูก deprecate แล้วให้ใช้ตัวนี้แทน) และ google.golang.org/protobuf Protocol Buffers Editions (ฉบับล่าสุดที่ปล่อยจริง: Edition 2024) กำลังมาแทน syntax keyword proto2/proto3 ในอนาคต แต่ไฟล์ proto3 ยังใช้งานได้เต็มรูปแบบ และ import ร่วมกับไฟล์ edition ได้อย่างอิสระ — syntax = "proto3" ที่ใช้ตลอดทั้งคอร์สนี้ยังทำงานได้เหมือนเดิม