forked from 0xWheatyz/SPARC
Refactor get_db_client() in auth.py to use a shared pooled DatabaseClient #1499
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
Roadmap item: P1 Error handling and resilience
get_db_client()inauth.pycreates a brand-newDatabaseClientinstance on every invocation. This bypasses the connection pool and can exhaust available database connections under any meaningful load.What to do
DatabaseClientinstance (or reuse the one already used by the rest of the API — confirm where the shared client lives).get_db_client()to return or depend on this shared instance rather than constructing a new one.DatabaseClientis instantiated across multiple auth calls.Acceptance criteria
get_db_client()does not construct a newDatabaseClienton each call[Repo Manager] This issue is already resolved.
SPARC/auth.pyuses a module-level singleton_db_clientwithinit_db_client()/close_db_client()lifecycle functions called from the FastAPI lifespan.get_db_client()returns the shared pooled instance. Closing as complete.