refactor(core): split base.py into pool_state, pool_manager, health#38
Open
Pavkazzz wants to merge 3 commits intorefactor/2-contractsfrom
Open
refactor(core): split base.py into pool_state, pool_manager, health#38Pavkazzz wants to merge 3 commits intorefactor/2-contractsfrom
Pavkazzz wants to merge 3 commits intorefactor/2-contractsfrom
Conversation
3 tasks
70a9cbb to
0778780
Compare
b31c004 to
fa55228
Compare
0778780 to
726bd15
Compare
fa55228 to
b4742f8
Compare
…onitor - PoolState (hasql/pool_state.py): manages master/replica sets, waiting, pool factory delegation — replaces the stub from PR2 - BasePoolManager (hasql/pool_manager.py): thin orchestrator; all pool-state queries exposed as public proxy properties/methods - PoolHealthMonitor (hasql/health.py): background health checks — takes pool_state + scalars instead of full manager reference (no transitive private access) - hasql/base.py: reduced to 23-line re-export shim for backward compat - hasql/utils.py: genericize Stopwatch[KeyT], fix Dsn.with_() scheme preservation, defensive copy for Dsn.params Stack 3/4 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace Metrics(drivers=..., hasql=...) with Metrics(pools=..., hasql=..., gauges=...) now that base.py uses the new pool_manager.py. Backward-compat drivers property converts PoolMetrics back to DriverMetrics. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
726bd15 to
d4a4c9c
Compare
b4742f8 to
9338dbf
Compare
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.
Summary
Stack 3/4 — splitting the monolithic
base.py(709 lines).PoolState: manages master/replica pool sets, waiting, factory delegationBasePoolManager: thin orchestrator with public proxy methods for the full APIPoolHealthMonitor: background role checks — no longer accesses manager's private attributesbase.py: reduced to a 23-line re-export shim for backward compatibilityutils.py: genericizeStopwatch[KeyT], fixDsn.with_()scheme preservation, defensive copy forDsn.paramsAll methods removed from
BasePoolManagerare re-exposed as public proxies (release(),terminate(),master_pool_count,closing, etc.).Review guide
hasql/pool_state.py→hasql/health.py→hasql/pool_manager.py→hasql/base.pyTest plan
ruff checkpassespytest tests/test_base_pool_manager.py tests/test_backward_compat.py tests/test_balancer_policy.py— 81 tests passpytest tests/test_abc.py— 5 tests pass (previously deselected in PR2)pytest tests/test_utils.py— 56 regression tests passtest_timeout_handling.py,test_trouble.py— require live PostgreSQL🤖 Generated with Claude Code