Allow using database/sql driver with functioning pgx listener#352
Draft
Allow using database/sql driver with functioning pgx listener#352
Conversation
1ebf29c to
4518593
Compare
7c7bac8 to
01aeece
Compare
Closed
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.
4518593 to
9b25b43
Compare
|
Any news on this? It would be incredible to get LISTEN/NOTIFY using the standard driver! |
|
Indeed, this would be nice to have. Is this being worked on? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Building on #351, this PR allows users to take advantage of the new
riverdatabasesqldriver while also keeping full support forLISTENand avoiding poll-only mode.This is accomplished through a
riverdatabasesql.NewWithListener()constructor that allows thedatabase/sqldriver to be used with a functioning listener implementation. Also adds ariverpgxv5.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/sqlor 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
*Txinsert variants bc we cannot tell when a transaction completes).