Urgent.News

What's breaking now, across thousands of outlets.

Tech

The Contract Is a .proto File

One handle, one source of truth - the HTTP spec is derived, not written. ๐Ÿ‘‹ Hi, I'm Anton - a software engineer working mostly in PHP/Symfony and Go, currently carving a live PHP monolith into Go services. This series is about the road from a requirement to a contract: what has to be true before anybody writes code. This part is the short one, with a single claim in it. Running notes live on myโ€ฆ

One shared contract repository holds the schema file, which declares every service-to-service call in the system. The build then converts this schema file into typed clients and servers for both sides of the call, while also producing the HTTP role of a handle. The claim is that the contract is declared in the schema and nowhere else.

Each aspect of the interface - messages, calls, field meanings, required fields, value bounds, and refusal codes - is all defined within the .proto file. This approach may initially seem like a style preference, but it becomes clear when considering the alternative of two documents that remain in sync by a person's memory. The case study demonstrates that both environment variables and metrics, which were previously described manually in code-specific files, are now kept as repository artifacts.

For variables declared by the service configuration, the catalog records the defined_in file and line of the declaration. For metrics declared by the platform, they are also recorded in the catalog. The metrics snapshot includes an entry per metric, plus a dynamic row for the runtime metric registration. The check process runs the generator in check mode whenever any relevant files change, ensuring that any drift is caught as a build failure.

Certain resources, like variables with runtime-generated names, are not included in the catalog. The conclusion is that a manually written description drifts, while a derived and checked description remains consistent. The HTTP handle is not considered a separate interface but rather the same contract with its role explicitly marked using an annotation, with the HTTP specification derived from the schema.

Written by urgent.news from Dev.to's reporting โ€” not their text. Machine-written โ€” may contain errors; check the original before relying on it.

Read the original at dev.to โ†’

More in Tech

Brilliant 11 years old

Hello, I'm an 11 years old moroccan developer nowing web stack development python and bash and go, so i made a domain creation detector daemon, so check it out here: domdaemon and thanks.

Benchmarking a Ryzen VDS Without Fooling Yourself: CPU Scheduling, Storage Latency, and Reproducible Tests

A virtual server benchmark is easy to run and surprisingly hard to interpret. A single attractive score can be caused by a short turbo window, a warm cache, an idle host, or a storage queue that doesโ€ฆ

  • Define test objectives with specific workload, vCPU count, memory, and storage allocation
  • Record environment details including date, CPU info, memory, and block device information
  • Establish consistent measurement window and avoid interfering activities during tests

More from Saturday 19 September โ†’