postgres
postgres copied to clipboard
LISTEN/NOTIFY support
I’m wondering if this library supports listen/notify or if it needs to be adapted slightly to. Any suggestions on the best approach on getting it working? I’ve used pg-notify in node and may need to port it for deno use if nothing exists yet.
Hey @ddibiase, there is not LISTEN/NOTIFY support yet, but it's on my roadmap. I expect it should land during next month or two. Feel free to contribute!
I'd be happy to contribute as I need to solve this for my side project. Would you mind giving some direction on how you'd like it implemented? I was considering porting andywer/pg-listen for Node. It's TS and very well written with a lot of nice features.
It has an dependencies on EventEmitter, TypedEventEmitter, pg and pg-format that could be replaced with simple alternatives. pg-format could actually be ported relatively easily.
Any thoughts?
@ddibiase yes please!
I made one pass reading pg-listen - I'll keep you posted today, this is something we definitely want to support. Functionality itself is pretty straight-forward, but we need to improve testing for this project, so it'd be good if there was a thorough test suite.
Sorry for the delay, I had to sit on this thing for a while. I hope to post a PR this week with prototype for this functionality.
I tried to give this a go, but it seems a bit hard given the architecture of deno-postgres: it only does readMessage() when expecting something, and from a bunch of different places.
This is in contrast to e.g. ts-postgres which has a single central message reader that's always open to accept messages.
Not sure how to adapt it to the notifications. Tips welcome.
@jakajancar to be honest I haven't really put much thought about this issue since it was opened. It is very likely that supporting listen/notify will require to rewrite significant parts of this lib.
That said, I'm open to such changes if we could discuss them first.