✨ feat(db): read SQLAlchemy engine pool configuration from config file#74
Conversation
#73) Move hardcoded engine pool parameters (pool_size, pool_timeout, pool_recycle, max_overflow) from factory function defaults into PostgresConfig, allowing per-environment tuning via YAML config. Also add pool_pre_ping (default: true) and echo_pool (default: false). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
PR Review: feat(db): read SQLAlchemy engine pool configuration from config fileOverall assessment: 🔶 Request Changes The change is well-motivated and cleanly structured. The PR description is thorough and the diff is easy to follow. However, there are a few issues that should be addressed before merging. Critical Issues1. No validation on the new pool fields
Problematic values that should be rejected:
The existing 2.
|
| # | Severity | Description |
|---|---|---|
| 1 | Critical | Add @field_validator guards for pool_size, pool_timeout, pool_recycle, max_overflow |
| 2 | Critical | Widen echo_pool type to Union[bool, Literal["debug"]] |
| 3 | Suggestion | Revisit default pool sizes or add a warning comment in config-example.yaml |
| 4 | Suggestion | Add a TestLoadConfig test case that round-trips the new pool fields through YAML |
| 5 | Minor | Note the create_engine function signature change in the PR description |
🤖 Generated with Claude Code
Pull Request
Description
Move hardcoded SQLAlchemy engine pool parameters from
create_enginefunction defaults intoPostgresConfig, allowing per-environment tuning via YAML config files. Also addspool_pre_ping(enabled by default) andecho_poolsupport.Type of Change
Testing
Code Quality
pre-commit run --all-files)ruff check src/ tests/)ruff format src/ tests/ --check)Related Issues
Fixes #73
Additional Notes
Changes
src/infrastructure/config.pyPostgresConfigwith sensible defaultssrc/infrastructure/db/factory.pycreate_engineto read all pool params from configconfig-example.yamltests/unit/infrastructure/test_config.pytest_pool_defaultsandtest_pool_custom_valuesNew config fields (all optional with defaults)
pool_sizepool_timeoutpool_recyclemax_overflowpool_pre_pingecho_poolNon-breaking: all new fields have defaults matching the previous hardcoded values.
Checklist for Reviewers:
🤖 Generated with Claude Code