feat: forward setup, server_settings, connection_class in pool/conn factories - #46
Open
rcbevans wants to merge 1 commit into
Open
feat: forward setup, server_settings, connection_class in pool/conn factories#46rcbevans wants to merge 1 commit into
rcbevans wants to merge 1 commit into
Conversation
…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
force-pushed
the
feat/auth-factory-params
branch
from
July 30, 2026 04:53
27dbd03 to
2eb7fe4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
make_pg_pool_factoryandmake_dedicated_conn_factorynow accept three new keyword-only parameters and conditionally forward them toasyncpg.create_pool/asyncpg.connect:setup-- per-acquire hook that runs on everypool.acquire(), distinct frominitwhich runs once per new physical connection. Use it for per-checkout work like resettingsearch_pathor verifying session state.server_settings-- session-level GUCs applied at connection time (e.g.{"statement_timeout": "30s", "search_path": "app"}).connection_class-- customasyncpg.Connectionsubclass for codec registration or method overrides.Backward compatibility
All three params default to
Noneand are omitted from the kwargs dict when not provided, following the sameif not Nonepattern as the existinginitandcommand_timeoutparams. Existing callers are byte-for-byte unaffected -- no new kwargs reach asyncpg when the params are absent.Tests
asyncpg.create_pool/asyncpg.connectverbatim (identity check on the passed object).auth.pyandtest_auth.py(replaced with plain ASCII).