forked from 0xWheatyz/SPARC
Refactor auth.py to use a shared pooled DatabaseClient instead of per-call instantiation #1621
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 invocation. Under concurrent load this bypasses connection pooling and can exhaust available database connections.What to do
DatabaseClient/ connection pool is initialised in the app (likelymain.pyordatabase.py).auth.pyso thatget_db_client()is a FastAPI dependency that returns the shared client rather than constructing a new one.Acceptance criteria
DatabaseClientinstance is shared across auth and all other request handlers.This issue has been resolved by previously merged PRs. The feature is already implemented in the codebase on main.
Closing as already resolved.