Skip to content

Conversation

djeebus
Copy link
Contributor

@djeebus djeebus commented Oct 17, 2025

  1. The pgxpool.Pool is the only way of connection to the database. Creation is centralized in db.NewPool
  2. If a *sql.DB is needed, db.Open(pool) can provide one. Connection pooling is still handled by the pgxpool.Pool.

Note

Centralizes Postgres connections via a shared pgxpool with OpenTelemetry, injects *sql.DB/pgxpool into services, and updates API, seeds, and tests to use the new pool and migration check.

  • Database (shared pkg):
    • Introduce db.NewPool (pgxpool) and db.Open to obtain *sql.DB; enable OTEL via otelpgx (traces + metrics).
    • Change db.NewClient to accept *sql.DB instead of creating connections.
  • API:
    • Config: add POSTGRES_MAX_CONNECTIONS and POSTGRES_MIN_IDLE_CONNECTIONS.
    • Main: create pool via db.NewPool, open *sql.DB, pass into handlers.NewAPIStore.
    • utils.CheckMigrationVersion now takes *sql.DB (no internal open/close).
    • handlers.NewAPIStore signature updated to receive injected DB (*sql.DB, *pgxpool.Pool).
  • SQLC client (packages/db/client):
    • Simplify NewClient to NewClient(pool *pgxpool.Pool); remove internal pool/options and tx helpers.
  • Docker Reverse Proxy:
    • Build pool in main, open *sql.DB, pass to handlers.NewStore; use shared db.NewClient with provided conn.
    • Add cache.ErrNotInCache sentinel error.
  • Local Dev + Seeds + Tests:
    • Migrate to db.NewPool/db.Open; update seed scripts and test helpers to use injected pool/clients.
  • Dependencies:
    • Add github.com/exaring/otelpgx and related OTEL/pgx deps across modules.

Written by Cursor Bugbot for commit 2109e4d. This will update automatically on new commits. Configure here.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@djeebus djeebus marked this pull request as draft October 21, 2025 03:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants