forked from 0xWheatyz/SPARC
Fix: share a single pooled DatabaseClient instead of creating one per request in auth.py #519
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.pyinstantiates a newDatabaseClienton every call. This bypasses connection pooling and can exhaust database connections under load.Task
auth.pyto use a module-level or application-level singletonDatabaseClientDepends) to provide the shared client to route handlersAcceptance Criteria
get_db_client()no longer creates a new client on every callDatabaseClientinstance is shared across all auth route handlersVerified complete:
auth.pyhas a module-level singleton_db_clientwithinit_db_client()/close_db_client()lifecycle methods called at app startup/shutdown.get_db_client()returns the shared instance. Closing as implemented.