sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Have a way to borrow the connection out of a PgListener

Open sandhose opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. I'm working on a job queue in my project, which involves NOTIFY/LISTEN. Ideally, I would like to react to notifications and reuse the same Postgres connection when I'm processing this notification.

Describe the solution you'd like

PgListener already implements Executor, which helps executing arbitrary queries with it, but my database abstraction would benefit from accessing the &mut PgConnection. PgListener has a connection private method which gives that, but maybe it should just implement Acquire?

Describe alternatives you've considered Opening a second connection, which feels wrong as when I'm processing notifications, the PgListener connection sits idle anyway.

Additional context -

sandhose avatar Oct 08 '24 13:10 sandhose