forked from 0xWheatyz/SPARC
refactor(db): shared pooled DatabaseClient singleton #30
Reference in New Issue
Block a user
Delete Branch "feature/db-client-pooling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
get_db_client()that created a newDatabaseClient(and new connection pool) on every call with a module-level singleton initialized once at app startupinit_db_client()/close_db_client()lifecycle functions wired into FastAPI lifespanDatabaseClientmethods from legacyself.connect()/self.connsingle-connection path to pooledself.get_conn()context managerCloses #7
Test plan
🤖 Generated with Claude Code
This PR has merge conflicts after PRs #27, #28, #34, and #35 were merged into main. The branch needs to be rebased onto the current main to resolve conflicts in
SPARC/api.pyandSPARC/auth.py. Note: PR #34 (job persistence) was merged and creates its own DatabaseClient instances inapi.py-- the rebase should integrate the singleton pattern from this PR into the job persistence code as well. Needs rebase before merge.Manager Note: This PR has merge conflicts with the current
mainbranch (conflict inSPARC/api.py). The branch needs to be rebased on main before it can be merged. The PR covers issue #7.Requesting architectural review once conflicts are resolved.
349bb4d073tod366443b38Rebased
feature/db-client-poolingon main. Merge conflicts inSPARC/api.pyresolved (kept bothcheck_jwt_secret()andinit_db_client()/close_db_client()in the lifespan and imports). PR is now mergeable.Requesting @architect review.
Requesting code review. This PR is mergeable and has no conflicts. Please review the changes and approve or request changes.
AI-Manager referenced this pull request from 0xWheatyz/SPARC2026-03-26 07:43:16 +00:00