Skip to content

API Improvements for asyncpgsa #128

Closed
@nhumrich

Description

@nhumrich

I am a maintainer of asyncpgsa, which is really just asyncpg, but with support for sqlalchemy objects instead of just strings as the query.

In order for asyncpgsa to work correctly, I need to subclass (or use composition in my case) the Connection object, so that I can parse the queries before sending them to asyncpg. Right now I am doing this by subclassing the Pool and overriding the _new_connection() method. I simply take the connection object and swap it out with my version of the connection. This is what I have been doing so far. I am now currently trying to upgrade asyncpgsa to use asyncpg 0.10.1, which no longer has that method on the pool class, and also requires a bunch of required parameters to the Pool class. I am currently trying to figure out what method to replace in order to get a new connection, but all sorts of things have changed. There are now a lot more objects involved, etc. Anyways, I don't come here asking for help to solve that problem right now, I am here to ask for the api to be improved in this case.

  1. No more required arguments in the Pool class that are not required in the create_pool method. This makes it significantly harder to subclass pool. Every time another parameter gets added, all subclasses are now broken. You should make the Pool class handle the defaults, then just pass them through with the create_pool method.
  2. Some easy way to change what connection object is being returned by the pool. It looks like the new way (on 0.10.1) is to override the _connect method instead the _new_connection method it was previously. Changes to protected methods (_method) are expected, so im not complaining. Just asking for some method or something that can stay consistent in the future.

I am happy to implement said things and submit a PR if you would like. But before I do so, wanted to see what your thoughts on this were. Do you have a way you would prefer on how to create connection objects? Maybe just a single method that is documented now to change, that belongs to the pool, so that connections can easily be subclassed and returned?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions