Every Door Must Open
The zoo map had doors drawn on it that did not open, and visitors found out by walking into them. Now every door on the map gets hinges from the plan, and a painted door fails the morning check. Built and tested in the shared library.
👋 Hi, I'm Anton - a software engineer. These days I work on a platform: contracts, generated code, data paths and the tooling around them. Running notes live on my GitHub: github.com/brilliant-almazov.
This part is about built and tested generator behaviour and two checks in a service's build. The "nine in ten" is a count one session made at its start and did not re-check; I give it rounded and say so on the figure.
This is part 16 of the series on what a shared platform does for every service, told as a zoo. Maybe you already do it better, maybe you'd do it another way - this is how it is going, and where it stops.
In real life
Biscuit runs at a door on the zoo map and bounces off it. "Ouch! It's painted on." The door is on the map, it has a number and a sign, and it is a picture on a wall. Nobody lied on purpose. The map was drawn first, and the doors were going to be cut later.
This part brings in a new resident: Penny, the most practical animal in the zoo. Penny counts every carrot, and on this morning Penny counts doors: "Painted, painted, painted... nine in ten." Nora does not believe it. Then Pip brings the fix from the plan: every door on the map gets hinges printed for it, and the keeper only writes what is inside the room. The last panel is Penny again, counting twice, because Penny always counts twice: zero painted. Biscuit asks the only question he has: can he run through now?
Doors that compile
A gRPC contract lists the methods of a service. In Go, the generated server type comes with a base that answers every method with the code Unimplemented, so a service can register itself and compile long before it writes a single method. That is convenient on the first day and dangerous on every day after it. A method that nobody wrote looks exactly like a method that exists: it is in the contract, it is in the generated client, the build is green, and the first one to find out is a caller.
In our platform the contract is generated too, and services are printed from a manifest. So the painted door had two places to hide: the contract that declares the rpc, and the service that never wrote it.
Hinges from the manifest
The fix is the same move the series keeps making: declare it, and let the generator print it. A service declares its gRPC surface in a grpc: section of the manifest. For every rpc the generator prints the adapter, the ports, the registration and a method. And the body of a small method can be written right in the manifest, so the printed method is complete. In the shape of the manifest - rpc and field names illustrative:
# service.yaml - every rpc gets an adapter, ports, registration and a method; an empty one fails the build grpc: service: <package>.<Service> rpcs: - name: GetOrder body: | # the printed method is complete return s.orders.Get(ctx, req.GetId()) - name: ListOrders # no body: the printed method waits for the hand-written inside An rpc without a method does not build. That is the hinge. The base that answers Unimplemented is still there in the generated code, but a service printed from the manifest can no longer quietly lean on it, because there is no rpc in the manifest that does not get its own method.
What the keeper still writes
Printing hinges does not mean printing rooms. The library's own rule for what stays hand-written is short, and this part sits right on its edge:
- the body of your own method and the business rules in it - a concrete contract in, a concrete contract out;
- the checks of meaning in tests, on top of the printed test skeleton;
- the decisions people make: which daemons a service runs, and which migrations are already applied and never edited.
A body in the manifest is for the method that is one line of delegation. Everything with a rule in it is still the keeper's room, and the printed method is the door to it.
Two checks that keep it at zero
The manifest closes the door from one side. The service's build closes it from the other. The generator prints a CI for every service with two checks that matter here. The first one is called, plainly, "gRPC methods implemented": any codes.Unimplemented in the service's gRPC handlers fails the build. The second one is "Generation drift": a printed file that someone edited by hand, or that no longer matches its manifest, fails the build too.
CI of a printed service - a form gRPC methods implemented fail on codes.Unimplemented in the gRPC handlers Generation drift fail when a printed file differs from a fresh print | Check | Zoo | Catches |
|---|---|---|
| a method printed per rpc | every door on the map gets hinges | an rpc nobody wrote |
| gRPC methods implemented | a painted door fails the morning check | a handler that still answers Unimplemented |
| generation drift | nobody repaints a door by hand | a printed file edited by hand |
| a walk over the running server | Penny pulls every handle | a door that is fine in code and painted in the build |
The last row is a guard that one service wrote for itself, and it is the strongest of the four. It starts the built server and calls every rpc of its contract, one by one, and fails on any Unimplemented. It does not trust the code; it pulls every handle.
What went wrong
The service that wrote that walk had a good reason. At the start of one working session, its own count was that about nine rpcs in ten answered Unimplemented. The contract was large and complete, the generated client was complete, the build was green - and almost every door was painted. That count was made by the session and not re-checked from the repository later, so I give it rounded and as a ratio, not as a measurement I stand behind to the unit.
The fix was not a heroic week of writing methods. It was the walk first, then a list of rpcs still waiting, then the list going down until it was empty. The walk made the waiting list visible; the list made the work countable; and the build check made sure it stays at zero.
What I take from it is not about gRPC. A system that lets "declared" and "done" look the same will drift toward declared. The generator's job is to make them look different - a printed method that will not build empty, a check that fails on the placeholder - so that the gap is a red build and not a surprised caller.
What I do not claim
- Not the exact count of painted doors. "Nine in ten" is rounded from one session's own count, not re-checked.
- Not that every service already declares its gRPC surface in the manifest. The section is built and tested.
- Not that the walk over the running server is in the library. One service wrote it.
- Not the exact manifest syntax. The YAML above is a form.
- Not that a body in the manifest fits every method. It fits small ones; the rest are written by hand.
What of this is method
- Declared is not done. Make the placeholder fail the build.
- Print a method per rpc. Every door on the map gets hinges.
- Pull every handle. A walk over the running server trusts nothing it did not call.
Zoo keeping, built in - Part 16. Next: Your Own Enclosure Layout.
If your gRPC services embed the unimplemented base, how would you know which methods are still painted? If you generate servers from a contract, does an empty method fail your build? If you counted your painted doors once, what was the ratio? Which door on your map is still a picture?










