DEV Community

Anton Brilliantov
Anton Brilliantov

Posted on

Six Complaints, One Delivery

Six Complaints, One Delivery - the cover: a zoo supply depot; Nora, the Menagerie and Basil, a guest with a big GUEST badge, hold six complaint notes between them at the depot window; Gus the quartermaster arrives driving one small delivery truck loaded with six labelled crates and gives a thumbs up

Six Complaints, One Delivery

Three visitors came to the supply depot on the same morning with six notes between them. The quartermaster did not make six trips. One truck, six crates, everyone signed for it. Built and tested in the shared library and shipped in one release.


👋 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 six built and tested library changes that shipped together, and three counts from a later delivery that went red. The counts are rounded.

This is part 18 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

The supply depot opens, and there is already a queue. Nora is first: "My keys are blocked!" The Menagerie is right behind, all of it at once: "Our folders, our names!" And then a face the zoo has not seen before.

A four-panel comic: Nora, worried, says my keys are blocked, and the Menagerie, worried, says our folders, our names; Basil next to a sign reading GUEST says my schema is not there yet; Gus next to two crates says not six trips, one delivery; Nora, Basil and the Menagerie, happy, and Basil says received, all six

This part brings in the last new resident of the series: Basil, a guest. Basil does not live in the zoo. Basil works with a host outside it - in the real platform, the service that talks to an outside database host - and visits with a GUEST badge on. Basil's note is the strangest of the six: "My schema is not there yet!" Gus, the quartermaster, reads all six notes, loads one truck, and drives it once. The last panel is everyone signing for it.

Three services, one upgrade

The platform is a shared Go library, and every service in the zoo is printed from it. After one library upgrade, three services hit it at the same time: the data-collection service (the Menagerie), the gateway (Nora), and the guest service (Basil). None of them was wrong. Each had found a place where the library assumed something that was true for the newest service and false for theirs.

Three tiles with faces: three services, worried; one change, proud; one release, happy; labels read six complaints, and all closed together; pills read built, tested and one release

The tempting answer is six small fixes. Each is a day of work, each gets its own release, and each service upgrades six times and finds the next gap on the way. That is a loop: a service waits for a release, upgrades, finds the next gap, waits again. With three services in it, every lap blocks someone.

Six notes on one page

So the six went onto one page, in plain words, and into one change.

A depot scene, no code: one truck with six crates for the six complaints - print folders fixed, one partition name format, the _URL guard lets plain keys pass, migrations before partitions (highlighted), a generic call wrapper refused, the gRPC adapter decorated; pills read built, tested and one release

1  print folders were fixed             -> layout: sets them              (collector)
2  partition name had one format        -> the name is set whole          (collector)
3  the _URL guard blocked plain keys    -> narrowed to resource keys      (gateway)
4  partitions ran before migrations     -> migrations first               (guest service)
5  a generic call wrapper was refused   -> accepted                       (guest service)
6  gRPC adapter was a concrete type     -> DI can decorate it             (one of the three)
Enter fullscreen mode Exit fullscreen mode

Two of them got their own parts earlier in this series: the print folders became Your Own Enclosure Layout, and the guard became A Cage You Cannot Wire By Hand. The other four are small enough to tell here.

The partition name. Partitions are a resource in the manifest: the server creates them on start, a worker creates them ahead on a schedule. The library used to build a partition's name in one format. The collector already had many tables partitioned by day with its own naming. Now the name is set whole in the manifest, and the library does not guess it. In the shape of the manifest - a form, key names illustrative:

# before - the library built the name in its own format
infra:
  postgres:
    main:
      partitions:
        events: { ... }
Enter fullscreen mode Exit fullscreen mode
# after - the name is set whole; the platform creates partitions under that name
infra:
  postgres:
    main:
      partitions:
        events:
          name: events_YYYYMMDD
Enter fullscreen mode Exit fullscreen mode

A night mover holds a manifest board with the partitions block - events, name: events_YYYYMMDD - and the same name is stamped on the archive gate

The order. The library runs a service's embedded migrations and creates its partitions. It used to create the partitions first. For a service whose migrations create the schema the partitions live in, that order meant "schema does not exist" on a clean start. Basil's note was that error. Now migrations run first, then partitions and enums.

The generic wrapper. The library has ready wrappers for a call - tracing, metrics, logging, a transaction - so that services stop writing their own. One generic dependency form of those wrappers was refused by the library's wiring, and the guest service had to write around it. Now it is accepted.

The adapter type. The printed gRPC adapter was a concrete type, and the wiring could not wrap it in a decorator - for metrics, for tracing, for anything. Every decoration the platform does elsewhere stopped at that door. Now the wiring can decorate it like any other port.

Complaint Who Zoo What changed
fixed print folders the Menagerie the burrows don't fit layout: sets them
one partition name format the Menagerie our names, not yours the name is set whole
the _URL guard Nora my keys are blocked narrowed to resource keys
partitions before migrations Basil my schema is not there yet migrations first
a refused generic wrapper Basil my tools don't fit accepted
a concrete adapter type one of the three nobody can wrap the door DI can decorate it

Bars: complaints 6; services that complained 3; changes that closed them 1; releases 1; Gus, proud, says one truck, six crates; a pill reads counted from the change

One truck, three stops

One change, one release, and each service upgraded once. The order of the stops does not matter; what matters is that nobody upgraded twice.

An animation: a parcel travels under four tiles - the library, collector, gateway, guest service - and the pill changes from six fixes, one change, one release, to folders and partition names fit, to its keys pass the guard, to migrations first, adapter decorated

Before and after: after one upgrade - 3 stuck, services, each on its own gap; 6, complaints in one loop - and one delivery - 1 change, six fixes together; 1 release, three services up; pills read built, tested and one release

Where the series stops

This is the last part, so here is the whole zoo in one breath. Every part was the same move from a different side: something every service used to write or decide by hand, declared once in a manifest or a library, printed for everyone, and guarded by a check that fails the build.

  • signs, cages and doors - printed from the plan, not drawn by each keeper;
  • settings and connections - declared in one place, read the same way by every service;
  • the edges - where the library assumed one shape - bent toward the services, not the other way round.

What it does not cover is what the keeper still writes: the inside of each room. That part stays by hand, and it should.

What went wrong

The truck itself arrived fine. The next delivery of the same kind is the one that taught me something, and it was not about any of the six. It went red three ways at once, and all three were about what got loaded on the truck rather than what was in the crates.

  • The dependency lock file came along with about 140 extra lines that a tidy step removed. A lock file had been committed together with the work, and it carried whatever the working copy had picked up.
  • A modernize linter found 4 places where the code used an older form of the language than it could.
  • A check of the library's public surface found about 125 exports and fields with no stated reason to be public.

Bars: exports and fields without a reason, about 125; extra lines in the dependency lock, about 140; modernize findings, 4; Gus, worried, says wrong crates on the truck; pills read rounded, and now checked before the push

None of it was a bug a service would ever see. All of it was a red build that cost a round trip. The fix was about the truck: the lock file no longer rides with the work, and the surface check runs before the push instead of after it. A big delivery is cheaper than six small ones only if loading it does not become its own source of red.

Service tiles with faces: collector happy, gateway happy, guest service happy, the library proud; the guard happy, partitions happy, migrations proud, the lock file bored; pills read built, tested and one release

What I do not claim

  • Not how long the services were stuck. That is not measured here.
  • Not that one change is always better than six. It was here, because the gaps came at once from one upgrade.
  • Not which of the three services needed the decorated adapter. I keep it as "one of the three".
  • Not the exact counts from the red delivery. They are rounded.
  • Not that the surface check is complete. It runs before the push now; what it misses, it misses.

What of this is method

  • Collect the notes before you drive. Gaps that come from one upgrade go out in one release.
  • The library bends, not the service. Each of the six was the library assuming one shape.
  • Check what is on the truck. A big delivery is only cheap if loading it stays green.

Zoo keeping, built in - Part 18. Next: The Access Guard Gets Printed Too.

If a library upgrade of yours broke several services at once, did you ship one fix or several? If your migrations create a schema, what runs before them on a clean start? If your lock file rides with your work, who checks what it carries? What was the last note someone left at your depot window?

Top comments (0)