-
Notifications
You must be signed in to change notification settings - Fork 147
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
Support PostgreSQL notifications. #360
Comments
How about pushing messages to a When recycling the connection it's also important to execute a Apart from those technical details I'm curious if this is really the right way to do it. A better aproach would be to create one connection to the database and issue all |
Yes, I ended up writing my own connection pool, and used a In my application, the notification is task specific: get a connection from the pool, do some writes, write to a channel, wait on for the response in the channel specific to the thing that was written, do some read, return the connection to the pool. The receiving channel will never be used again, or by other client. |
By now it seems kinda obvious that the design of my application is dump. Instead of block one connection waiting for a channel notification, I think the following is the right approach: We must have one connection, outside of the pool, just to handle the channel subscription/notification. Lets call it the The This can be implemented in a completely independent library from |
Yes. That's the approach I've been promoting ever since. The connection that handles all the subscriptions is typically long lived and will subscribe to all the topics the application is interested in. You will never ever want to release this connection back to the pool. It might still be useful to have this feature as part of |
I need to receive PostgreSQL asynchronous notifications in my application.
At
ConfigConnectImpl<T>::connect()
, a task is created awaiting for thetokio-postgres
connection to run to completion. This discards every notification received by the client.Instead of simple
await
on the connection,deadpool-postgres
could usetokio_postgres::Connection<S, T>::poll_message()
to received notifications. It could buffer them aVecDeque
, like the synchronouspostgres
wrapper aroundtokio-postgres
does it. Or at least allow us to register a callback, for the duration of the borrow, to handle them.The text was updated successfully, but these errors were encountered: