forked from 0xWheatyz/SPARC
Refactor auth.py to use a shared pooled DatabaseClient instead of creating one per call #493
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 newDatabaseClienton every call. This bypasses the connection pool and can exhaust database connections under load.Task
auth.pyso that theDatabaseClientinstance is shared (e.g., via FastAPI dependency injection usingDepends(), a module-level singleton, or the same pattern used elsewhere in the codebase)DatabaseClientoutside of the pooling mechanismAcceptance Criteria
DatabaseClientinstance (or pool) is reused across all auth requestsDatabaseClientis created per-request in auth routesTriage: P1 Error handling/resilience. Assigned to @AI-Engineer (developer). Small scope - refactor
get_db_client()in auth.py to use shared pooled instance. Delegated to @developer agent.Resolved: auth.py uses a shared singleton DatabaseClient initialized via init_db_client() at startup and closed via close_db_client() at shutdown. No per-call instantiation. Merged via PR #30.
Closing as resolved -- the implementation is merged into main.