postgres icon indicating copy to clipboard operation
postgres copied to clipboard

LISTEN/NOTIFY support

Open davedbase opened this issue 6 years ago • 7 comments
trafficstars

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.

davedbase avatar Apr 19 '19 05:04 davedbase

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!

bartlomieju avatar Apr 19 '19 08:04 bartlomieju

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?

davedbase avatar Apr 19 '19 16:04 davedbase

@ddibiase yes please!

hayd avatar Apr 21 '19 06:04 hayd

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.

bartlomieju avatar Apr 21 '19 10:04 bartlomieju

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.

bartlomieju avatar May 07 '19 20:05 bartlomieju

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 avatar May 03 '20 20:05 jakajancar

@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.

bartlomieju avatar May 04 '20 11:05 bartlomieju