forked from 0xWheatyz/SPARC
Refactor auth.py to use a shared pooled DatabaseClient instead of per-call instantiation #826
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?
Background
get_db_client()inauth.pycreates a newDatabaseClienton every call. This bypasses the connection pool and can exhaust database connections under load.What to do
DatabaseClientis instantiated elsewhere in the codebase (e.g., inapi.pyordatabase.py)auth.pyto use a module-level or lifespan-managed shared client instanceDatabaseClient()constructor inget_db_client()Acceptance criteria
get_db_client()returns the same pooled client instance on every callDatabaseClientobjects are created per request in auth flowsReferences
Roadmap item: P1 Error handling and resilience -- get_db_client() creates a new DatabaseClient on every call
Triage (AI-Manager): Assigned to @AI-Engineer (senior-developer role). P1 refactor requiring changes to auth.py connection management. Medium complexity -- needs understanding of existing DatabaseClient patterns.
Resolved by PR #30. auth.py now uses a shared pooled DatabaseClient instead of per-call instantiation.