Skip to content

refactor(foundations): exception hierarchy, constants, enriched metrics - #36

Merged
mosquito merged 13 commits into
masterfrom
refactor/1-foundations
Sep 4, 2026
Merged

mosquito merged 13 commits into
masterfrom
refactor/1-foundations

Conversation

@Pavkazzz

@Pavkazzz Pavkazzz commented Apr 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

Stack 1/7 — foundations required by later refactor layers, without changing pool-manager behavior.

  • Add the HasqlError exception hierarchy.
  • Extract shared timeout, refresh, weight, and stopwatch constants.
  • Add enriched metrics models while retaining DriverMetrics compatibility.
  • Enable CI for stacked pull requests.

Stack

Base: master
Next: #37

Verification

  • Focused exception and metrics tests passed locally.
  • Ruff passed.
  • Required GitHub CI: lint, mypy, and Python 3.10–3.14 PostgreSQL test matrix.

…ed metrics model

- Add HasqlError, PoolManagerClosedError, NoAvailablePoolError,
  UnexpectedDatabaseResponseError, PoolManagerClosingError
- Add DEFAULT_ACQUIRE_TIMEOUT, DEFAULT_REFRESH_DELAY, DEFAULT_REFRESH_TIMEOUT,
  DEFAULT_MASTER_AS_REPLICA_WEIGHT, DEFAULT_STOPWATCH_WINDOW_SIZE constants
- Enrich metrics model: PoolRole, PoolStats, PoolMetrics, HasqlGauges,
  CalculateMetrics; retain DriverMetrics for backward compat
- Add Makefile with uv-based develop/ruff/mypy/test targets

Stack 1/4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pavkazzz and others added 5 commits April 16, 2026 09:54
packaging is still imported by hasql/asyncpg.py on master.
It will be removed in PR4 (refactor/4-drivers) when the driver
switches to a manual version parser.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Metrics(drivers=..., hasql=...) must work until PR3 replaces base.py.
New PoolMetrics/HasqlGauges types are pure additions; Metrics will be
updated to use them in PR3 (refactor/3-core).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
test_metrics.py from the PR branch uses _pool_state which doesn't
exist until PR3. Keep master's version here; PR3 will bring the
updated tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pavkazzz and others added 7 commits September 4, 2026 10:52
refactor(compat): preserve legacy import paths
refactor(drivers): extract drivers into hasql/driver/ package
refactor(core): split base.py into pool_state, pool_manager, health
refactor(contracts): PoolDriver ABC, acquire contexts, balancer refactoring
@mosquito
mosquito merged commit 640f28c into master Sep 4, 2026
7 checks passed
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