Building Services
From contract to running code
Section titled “From contract to running code”You have a .proto contract. This module turns it into something that actually runs: a server that answers calls, a client that makes them, and the deadline discipline that keeps the whole thing from hanging forever.
Every lesson uses the same tiny contract so you can follow one example end to end:
syntax = "proto3";package user.v1;
message GetUserRequest { int64 id = 1;}
message User { int64 id = 1; string name = 2; string email = 3;}
service UserService { rpc GetUser(GetUserRequest) returns (User);}What this module covers
Section titled “What this module covers”| Lesson | What you’ll learn |
|---|---|
| Code Generation | protoc, language plugins, buf, and exactly what gets generated |
| Implementing a Server | Filling in the handler, registering the service, and serving |
| Writing a Client | Channels, stubs, making the call, and reusing connections |
| Deadlines & Cancellation | Why every call needs a deadline, and how it propagates |
The shape of the work
Section titled “The shape of the work”flowchart LR proto[".proto"] -->|protoc / buf| gen["generated code: messages + stub + server interface"] gen --> srv["implement server (fill GetUser)"] gen --> cli["write client (call GetUser)"] cli -->|HTTP/2| srv
Notice that the generated code sits in the middle: it hands the server an interface to implement and the client a stub to call. You write the two ends; codegen guarantees they agree.