labkit/v2/postgres: Database load balancing — extract Container Registry read/write splitting

Context

The Container Registry has a production-proven Go implementation of database load balancing: read/write splitting, replica routing, and LSN-based connection sticking. This code is a candidate for extraction into LabKit v2 so all satellite services can benefit.

Flagged in the Artifact Registry PoC assessment.

Dependency

This work depends on the database/sql interface issue (team-tasks#4290). The Container Registry load balancing code is built on database/sql. It cannot be extracted into LabKit v2 until LabKit's postgres package exposes a database/sql-compatible interface.

Tasks

  • Confirm database/sql interface (#4290 (closed)) is merged first
  • Review and understand the Container Registry's load balancing implementation
  • Design the LabKit v2 abstraction: configuration, interface, integration with app.Component
  • Extract and adapt the Container Registry code into a postgres sub-package or option
  • Add support for read replicas, write routing, and LSN-based sticking
  • Test with a multi-node Postgres setup (primary + replica)
  • Update go-service-template with an example

References