Skip to content

feat: forward setup, server_settings, connection_class in pool/conn factories - #46

Open
rcbevans wants to merge 1 commit into
mainfrom
feat/auth-factory-params
Open

feat: forward setup, server_settings, connection_class in pool/conn factories#46
rcbevans wants to merge 1 commit into
mainfrom
feat/auth-factory-params

Conversation

@rcbevans

Copy link
Copy Markdown
Contributor

Summary

make_pg_pool_factory and make_dedicated_conn_factory now accept three new keyword-only parameters and conditionally forward them to asyncpg.create_pool / asyncpg.connect:

  • setup -- per-acquire hook that runs on every pool.acquire(), distinct from init which runs once per new physical connection. Use it for per-checkout work like resetting search_path or verifying session state.
  • server_settings -- session-level GUCs applied at connection time (e.g. {"statement_timeout": "30s", "search_path": "app"}).
  • connection_class -- custom asyncpg.Connection subclass for codec registration or method overrides.

Backward compatibility

All three params default to None and are omitted from the kwargs dict when not provided, following the same if not None pattern as the existing init and command_timeout params. Existing callers are byte-for-byte unaffected -- no new kwargs reach asyncpg when the params are absent.

Tests

  • Each param is verified to reach asyncpg.create_pool / asyncpg.connect verbatim (identity check on the passed object).
  • A backward-compat guard test confirms none of the new kwargs appear when the params are not provided.
  • Also cleaned up emdashes and box-drawing section dividers in auth.py and test_auth.py (replaced with plain ASCII).
uv run ruff format .  # 475 files left unchanged
uv run ruff check .   # All checks passed
uv run pytest tests/test_auth.py  # all pass

@rcbevans
rcbevans requested review from XBeg9, clinzy and kjw-azx July 29, 2026 04:28
@rcbevans rcbevans self-assigned this Jul 30, 2026
…actories

make_pg_pool_factory and make_dedicated_conn_factory now accept and
conditionally forward setup, server_settings, and connection_class to
asyncpg.create_pool / asyncpg.connect, using the same if-not-None
pattern as the existing init and command_timeout params.

setup is the per-acquire hook (runs on every pool.acquire), distinct
from init which runs once per new physical connection. server_settings
applies session-level GUCs (statement_timeout, search_path).
connection_class sets a custom Connection subclass for codec registration
or method overrides.

All params default to None and are omitted from kwargs when not
provided, so existing callers are byte-for-byte unaffected.

Tests verify each param reaches asyncpg verbatim and that the
backward-compat guard holds (no new kwargs when params are absent).
@rcbevans
rcbevans force-pushed the feat/auth-factory-params branch from 27dbd03 to 2eb7fe4 Compare July 30, 2026 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant