Skip to content

Conversation

@bgentry
Copy link
Contributor

@bgentry bgentry commented May 14, 2024

Building on #351, this PR allows users to take advantage of the new riverdatabasesql driver while also keeping full support for LISTEN and avoiding poll-only mode.

This is accomplished through a riverdatabasesql.NewWithListener() constructor that allows the database/sql driver to be used with a functioning listener implementation. Also adds a riverpgxv5.NewListener() constructor to allow creating a listener with a raw pgx pool.

These can be combined to allow full listener support as long as the underlying database driver supports it, even when it's used within an abstraction like database/sql or Bun.

Needs tests if we want to proceed with this. I'm pleased with how little code it took to achieve though!

You could imagine this being used in the future with a non-Postgres listener implementation such as Redis, though for that to work we may need to loosen notifications to be emitted outside of a transaction (and may not be able to emit them automatically at all for the *Tx insert variants bc we cannot tell when a transaction completes).

@bgentry bgentry requested a review from brandur May 14, 2024 02:16
@bgentry bgentry force-pushed the bg-dbsql-with-listener branch from 1ebf29c to 4518593 Compare May 23, 2024 14:41
@brandur brandur force-pushed the brandur-functional-database-sql branch 3 times, most recently from 7c7bac8 to 01aeece Compare July 6, 2024 00:51
Base automatically changed from brandur-functional-database-sql to master July 6, 2024 01:00
@bgentry bgentry mentioned this pull request Aug 14, 2024
Add a `NewWithListener` constructor to `riverdatabasesql` that allows
the `database/sql` driver to be used with a functioning listener
implementation. Also add a `NewListener` constructor to the `riverpgxv5`
driver to allow creating a listener with a raw pgx pool.

These can be combined to allow full listener support as long as the
underlying database driver supports it, even when it's used within an
abstraction like `database/sql` or Bun.
@bgentry bgentry force-pushed the bg-dbsql-with-listener branch from 4518593 to 9b25b43 Compare October 3, 2024 01:22
@leaanthony-sc
Copy link

Any news on this? It would be incredible to get LISTEN/NOTIFY using the standard driver!

@dragondgold
Copy link

Indeed, this would be nice to have. Is this being worked on?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants