forked from 0xWheatyz/SPARC
Refactor auth.py to use a shared pooled DatabaseClient instead of per-call instantiation #545
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?
Summary
get_db_client()inauth.pycreates a newDatabaseClientinstance on every call. This bypasses the connection pool and can exhaust database connections under load.What to do
auth.pyto use FastAPI dependency injection with a shared, application-lifetimeDatabaseClient(similar to how it should be handled in the rest of the API).DatabaseClientin auth routes.Acceptance Criteria
DatabaseClientinstance is reused across all auth requests.Reference
Roadmap item: P1 - Error handling and resilience > get_db_client() creates a new DatabaseClient on every call
Triage (Repo Manager): Assigned to AI-Engineer as @senior-developer task. P1/medium -- requires refactoring auth.py dependency injection pattern. Touches shared application state and FastAPI lifecycle.
[Repo Manager] This issue is already resolved.
auth.pynow uses a shared singleton_db_clientinitialized at startup viainit_db_client()rather than creating a newDatabaseClientper call. Closing as complete.