Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: LISTEN support (ie. NotificationResponse) #62

Open
andrepl opened this issue May 5, 2015 · 6 comments
Open

Feature Request: LISTEN support (ie. NotificationResponse) #62

andrepl opened this issue May 5, 2015 · 6 comments

Comments

@andrepl
Copy link

andrepl commented May 5, 2015

the _MSG_NOTIFICATION_RESPONSE is defined in the code, but the message type is not implemented.

There are a few ways to implement this, but simply providing a conn.listen("channel") that returns a stream seems the most obvious and idiomatic to me. the postgres listen command operates 'per-connection' and doesn't block, so I'm not sure how this would interact with pools (if at all).

@xxgreg
Copy link
Owner

xxgreg commented May 5, 2015

Thanks for the feedback. I'm happy to take patches - but I am not planning on adding this at the moment.

Good point about the connection pools and listen. I guess you'd always want to have a separate connection (not from a pool) open to handle listen responses.

@adaojunior
Copy link

Thank you for the package, it's very helpfull,
and I'll also add a +1 for this feature, I was going to use it to create a pubsub in my app but unfortunately there's no LISTEN support.
I take a look in the source code but I'm not sure if I'm able to implement this by myself.

@aabluedragon
Copy link

Yet another +1 for this feature request.

@aabluedragon
Copy link

aabluedragon commented May 31, 2016

I've forked and added support for retrieving Notifications.
See https://github.com/aabluedragon/dart_postgresql.git
Works in a similar fashion to the Java PostgreSQL getNotification() method (where polling seems to be the way to do this in the Java Driver as well).

@Fox32
Copy link
Contributor

Fox32 commented May 31, 2016

Wouldn't a Stream based API be more suiteable for Dart?

@aabluedragon
Copy link

aabluedragon commented May 31, 2016

It would, but I haven't found a way to have the PostgreSQL connection just give you the received pending notifications without "asking" for it.
Java also has Streams, yet the official PostgreSQL driver also works that way over there.
You can wrap the call to getNotification() with an interval timer, and have it load the upcoming notifications to a Stream using Dart's StreamController.

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

No branches or pull requests

5 participants