MagicStack / MagicStack/asyncpg
Support a Pool `before_connect` callback to be used before a connection is created
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 8.1k
- フォーク
- 468
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
- asyncpg version: 0.27.0
- PostgreSQL version: 14
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: Local - Python version: 3.9.9
- Platform: macos
- Do you use pgbouncer?: no
- Did you install asyncpg with pip?: yes
- If you built asyncpg locally, which version of Cython did you use?:
- Can the issue be reproduced under both asyncio and
uvloop?:
Hello! This is more of a feature request but I was wondering if there could be support for having a before_connect or similar callback when creating a Pool object that would run before a new connection is created? I see there is already an init param which is run after a connection is made.
Our use case is that we use dynamic credentials to access our postgres database and want to make sure that when we create a connection we are using credentials that are not stale. Is this something that makes sense for this project? There is similar functionality in other libraries such as sqlalchemy or pgx.
I was looking at how to do this as-is and there were two currently that I was exploring. One way would be to create our own Pool class which seems like a lot of maintainance for what we'd like to do. The other looked at creating a subclass and overriding the acquire and using set_connect_args but that would run every time we get a connection from a pool which would be wasteful as opposed to just when the creation happens.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
asyncpg/pool.pyから始め、特に既存のinitコールバックとissueで説明されているacquire/set_connect_argsの経路を確認して、接続がいつ作成され、いつプールからチェックアウトされるのかを理解します。新しいプール接続が作成されたときにのみbefore-connectフックで動的な認証情報を更新でき、毎回のacquireでは更新されないようになれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- postgresql, python
- 領域
- database
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100