forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to reuse a pooled DatabaseClient #70
Reference in New Issue
Block a user
Delete Branch "%!s()"
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?
Context
get_db_client()inauth.pycreates a newDatabaseClientinstance on every call. This bypasses the connection pool and can exhaust database connections under load.Work
DatabaseClientmanages its connection pool.get_db_client()to return a module-level or application-scoped singleton client, using FastAPI dependency injection (Depends) where appropriate.Acceptance Criteria
DatabaseClientinstance is shared across all auth requests.References
Roadmap: Error handling and resilience —
get_db_client()creates new client on every call.Resolved.
DatabaseClientnow uses aThreadedConnectionPoolsingleton pattern. Implemented in PR #30 (merged). SeeSPARC/database.py.