Files
substrate/docs/code-style-guide.md
T
Jet Chiang 60073ecd57 Replace ateredis with atepg (#940)
## Summary

A follow up to #640 where we introduced PostgreSQL as an alternative
storage backend, selected conditionally in ateapi.

- Deleted ateredis, its tests, and its dependencies
- Removed Redis backend selection and configuration so ateapi always
connects to Postgres
- Replaced Valkey resources with Postgres in the standard and Kind
deployment paths and simplified install script
- Replaced miniredis fixtures with isolated Postgres testcontainers and
added centralized helpers for seeding resources
- Renamed Redis-specific debug flush command to backend-neutral
`debug-clear-store` in CLI
- Updated comments and docs where applicable

## Benchmarking

Extensive benchmarking have been performed to evaluate Redis vs
Postgres, and results can be found in these two documents:

-
https://docs.google.com/document/d/10K0wB6aTeFkJCL4HN3NbLJCdFGoLYdhIcqkFnqFHkKc/edit?usp=sharing
-
https://docs.google.com/document/d/12-ko_BFHcBo_nJkx9f4B7zMbiiWKC2saGhMhZG3aQ-s/edit?usp=sharing

---------

Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
2026-08-25 07:23:40 -04:00

1.9 KiB

Code Style Guide

Go conventions for this repository — written for humans and coding agents alike. The API style guide governs the proto surface; this document governs the Go code behind it. Repository layout is covered by code layout.

The baseline is Effective Go, the Google Go style guide, and gofmt. This document records only decisions that are specific to this project.

Proto field access: check presence, don't default it

Generated getters (e.g. req.GetActor().GetName()) return zero values when any message in the chain is nil. That is convenient and dangerous: a required message the caller forgot to set silently becomes "", and the bug surfaces far from its cause.

  • A getter chain must never stand in for a presence check. Whenever a field is required at this point in the code, check it explicitly and fail loudly: INVALID_ARGUMENT at the API boundary, a real error (not a guessed zero value) elsewhere.

  • Once the boundary has validated presence, getters downstream are fine, as is the guarded form for optional messages:

    if wass := worker.Assignment; wass != nil {
        // Fields of wass were validated on write; use them directly.
    }
    
  • Absence of a group of fields that are set and cleared together is represented by a nil message (worker.Assignment == nil), never by probing a scalar field inside it for its zero value.

Testing

  • Standard library testing only — no assertion or mocking frameworks.
  • Table-driven tests with t.Run subtests are the default shape.
  • Prefer a real test implementation when one exists: the PostgreSQL test fixture for the store, envtest for the Kubernetes API. Release resources with t.Cleanup.

TODOs

Deferred decisions are recorded in code as TODO(<issue-number>): ..., placed where the decision will eventually have to be made.