refactor(contracts): PoolDriver ABC, acquire contexts, balancer refactoring#37
Open
Pavkazzz wants to merge 1 commit into
Open
refactor(contracts): PoolDriver ABC, acquire contexts, balancer refactoring#37Pavkazzz wants to merge 1 commit into
Pavkazzz wants to merge 1 commit into
Conversation
3 tasks
0778780 to
726bd15
Compare
…efactoring - Add PoolDriver ABC (hasql/abc.py): formal interface for all DB drivers - Add acquire context classes (hasql/acquire.py): AcquireContext protocol, TimeoutAcquireContext, PoolAcquireContext with deadline-based timeout budget - Add minimal PoolStateProvider protocol (hasql/pool_state.py stub) - Refactor balancer policies to depend on PoolStateProvider protocol instead of concrete BasePoolManager — eliminates circular import - Simplify RandomWeightedBalancerPolicy weight formula (MACHINE_EPSILON removed) Stack 2/4 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
726bd15 to
d4a4c9c
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 2/4 — interfaces and protocols.
PoolDriverABC: formal interface for all DB driversAcquireContext,TimeoutAcquireContext,PoolAcquireContext: connection acquire contexts with deadline-based timeoutsPoolStateProviderProtocol: balancers now depend on Protocol instead of concrete manager — eliminates circular importRandomWeightedBalancerPolicy: simplified weight formulaNote:
hasql/pool_state.pyin this PR contains only the Protocol stub. FullPoolStateimplementation comes in PR3.Review guide
hasql/abc.py→hasql/acquire.py→hasql/balancer_policy/base.py→greedy.py,random_weighted.py,round_robin.pyTest plan
ruff checkpassespytest tests/test_acquire.py tests/test_policy.py— 17 tests passtest_abc.pytests deselected (depend on updated mock from PR3)🤖 Generated with Claude Code