-
-
Notifications
You must be signed in to change notification settings - Fork 478
Add asynchronous notification support #19
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
Comments
A decent first pass on #19, but there really needs to be better support for polling for notifications than making a query and calling next() every once in a while.
+1 for NOTIFY support. Some notes: Besides issuing a query blocking on NOTIFY, some PG libs also supports a 2nd mode: add the file descriptor of the connection LISTENing to a select/poll'ed set (e.g. http://pythonhosted.org/psycopg2/advanced.html#asynchronous-notifications). In fact, psycopg2 allows to run all queries in an async style (http://pythonhosted.org/psycopg2/advanced.html#asynchronous-support) making use of the async support in libpq (http://www.postgresql.org/docs/current/static/libpq-async.html). |
Rust's new IO system doesn't currently have support for select/poll/etc. One option that may be reasonable in the sort term is to have a Async queries shouldn't be too tough to add. It's a little sad that they'll make the interface more dangerous at runtime since you can't make any other queries while an async query is executing. Right now, the closest thing to this is the |
"Rust's new IO system doesn't currently have support for select/poll/etc.": that is .. limiting. OT: what about |
The new IO system ( |
+1 |
@msierks What kind of functionality are you looking for? The options I see are a nonblocking iterator (sort of what we have now), a blocking iterator, or a callback based system, or some combination of the above. |
I like the non-blocking iterator, but a blocking one with an optional timeout would be great if possible. Similarly to the wait_for_notify method in the ruby PostgreSQL adapter. http://www.rubydoc.info/gems/pg/PG/Connection#wait_for_notify-instance_method Currently, the only issue with the non-blocking iterator is I cannot periodically check the iterator for new notifications. I don't receive the notifications unless I do some other sql actions. Does that sound right or am I doing something improperly ? |
Yep, that's correct right now. Makes sense! |
There's now a |
The setup is a little hairy, but seems correct. cc #19
@msierks http://sfackler.github.io/doc/postgres/struct.Notifications.html#method.next_block_for |
@sfackler I haven't had a chance to implement it yet, but I believe it should. I will let you know once I have. |
@sfackler Yup, this fits my needs perfectly. Thanks! :) |
Cool! I'm going to close this issue. If future feature requests come up, feel free to open a new one. |
A handler based approach like
set_notice_handler
doesn't really make sense here, since the common response to a notification is probably going to be querying for updated data.Something like libpq's
PGnotices
seems like the most straightforward solution, but both blocking and polling options both seem like they'd be useful.The text was updated successfully, but these errors were encountered: