ef385340e8
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
19 lines
582 B
Python
19 lines
582 B
Python
"""FastAPI dependencies — per-request wiring (SD-0001 §6.2 platform/deps).
|
|
|
|
Yields a pooled connection per request. The pool lives on app.state, built once in
|
|
create_app(). Later slices add the current-session and mailer dependencies here.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Iterator
|
|
|
|
import psycopg
|
|
from fastapi import Request
|
|
|
|
|
|
def get_conn(request: Request) -> Iterator[psycopg.Connection]:
|
|
"""A pooled connection for the duration of one request."""
|
|
pool = request.app.state.pool
|
|
with pool.connection() as conn:
|
|
yield conn
|