MagicStack / MagicStack/asyncpg
feat: allow connection with pre-configured socket
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
I'd like to add support for creating a postgres connection over an existing socket like object. In this approach startTLS can or cannot be used depending on the caller. This lines up similarly with what we have in Java ([socketFactory connection param](https://jdbc.postgresql.org/documentation/use/#connection-parameters), [driver code](https://github.com/pgjdbc/pgjdbc/blob/aff581fe806f1c1cdc8bcd9e5a981e37691b44b5/pgjdbc/src/main/java/org/postgresql/core/SocketFactoryFactory.java#L25-L47)), Go ([pgx DialFunc](https://pkg.go.dev/github.com/jackc/pgconn#DialFunc)) (these two are slightly different as they allow specifying a creator/generator func that creates the socket, while here we could just pass in the socket directly but the extent of the feat is the same), and other Python libraries ([pymysql](https://github.com/PyMySQL/PyMySQL/blob/main/pymysql/connections.py#L626), and [pg8000](https://github.com/tlocke/pg8000/pull/136))
The equivalent pymysql PR that introduced this change explains the feature really well https://github.com/PyMySQL/PyMySQL/pull/355
The benefit of this feature is that it allows the user to specify their own secure tunnel to connect over (such as ssh).
Is this sort of feat possible for asyncpg?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing asyncpg's connection setup and compare the socketFactory, DialFunc, and PyMySQL references linked in the issue. Determine how an existing socket and optional startTLS would fit the API, then verify completion with coverage for both TLS choices and tunneled connections.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100