Repository navigation
MOS-13: Add pgx pool, postgres config block and docker-compose - #17
Merged
Merged
Conversation
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>
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.