Skip to content

MOS-13: Add pgx pool, postgres config block and docker-compose - #17

Merged
timoruohomaki merged 2 commits into
masterfrom
feat/MOS-13-pgx-pool
Nov 8, 2026
Merged

timoruohomaki merged 2 commits into
masterfrom
feat/MOS-13-pgx-pool

Conversation

@timoruohomaki

Copy link
Copy Markdown
Contributor

internal/store/postgres/pool.go builds a pgxpool with max/min conns, health checks and a connect timeout, and pings at creation so bad settings fail at startup. Outside development every connection must use sslmode=verify-full (checked on the resulting TLS settings, so PGSSLMODE counts too). Parse errors are withheld because pgx redacts passwords only best-effort; logs name host, database and user only.

Config gains a postgres block; DATABASE_URL (backend01 .env name) overrides postgres.url, POSTGRES_* override pool settings, and without a URL the standard PG* variables apply. The generated config never contains a URL.

The server connects at startup when a database is configured and exits if it cannot; repositories stay in memory until MOS-16.

docker-compose.yml runs postgres:17 on 127.0.0.1 with an openmos_test database for the store tests. Docs cover the config and setup.

internal/store/postgres/pool.go builds a pgxpool with max/min conns,
health checks and a connect timeout, and pings at creation so bad
settings fail at startup. Outside development every connection must use
sslmode=verify-full (checked on the resulting TLS settings, so
PGSSLMODE counts too). Parse errors are withheld because pgx redacts
passwords only best-effort; logs name host, database and user only.

Config gains a postgres block; DATABASE_URL (backend01 .env name)
overrides postgres.url, POSTGRES_* override pool settings, and without
a URL the standard PG* variables apply. The generated config never
contains a URL.

The server connects at startup when a database is configured and exits
if it cannot; repositories stay in memory until MOS-16.

docker-compose.yml runs postgres:17 on 127.0.0.1 with an openmos_test
database for the store tests. Docs cover the config and setup.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Comment thread src/internal/config/env.go Fixed
Comment thread src/internal/config/env.go Fixed
CodeQL flagged int32(strconv.Atoi(...)) for POSTGRES_MAX_CONNS and
POSTGRES_MIN_CONNS: an out-of-range value would wrap around. Parse them
with strconv.ParseInt(s, 10, 32) instead, falling back to the default
like the other env helpers, and reject negative pool sizes in
ParsePoolConfig.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@timoruohomaki
timoruohomaki merged commit d03fb24 into master Nov 8, 2026
3 checks passed
@timoruohomaki
timoruohomaki deleted the feat/MOS-13-pgx-pool branch November 9, 2026 17:07
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