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 for LISTEN / NOTIFY -- Feedback wanted! #496

Closed
jakob opened this Issue Feb 16, 2018 · 9 comments

Comments

Projects
None yet
3 participants
@jakob
Owner

jakob commented Feb 16, 2018

Hi everyone!

I've been working on adding support for LISTEN / NOTIFY to Postico.

There's a lot we could do with those commands, but for now I've decided to just show a notification whenever a NOTIFY message is received from the server.

Here's how to use it:

  1. Download the latest prerelease build of Postico

  2. Connect to a database and execute the command LISTEN some_channel_name;

  3. From a different connection, execute NOTIFY some_channel_name, 'Some Informative Text';

The main use case I have in mind for this is debugging applications that use LISTEN/NOTIFY.

Does anybody use LISTEN / NOTIFY with PostgreSQL? I'd love to hear about your use cases, and if you'd use this feature in Postico.

@postico-bot

This comment has been minimized.

postico-bot commented Feb 16, 2018

We have been working on this issue!

jakob: Merge branch 'listen-notify' #496

Download Build B2417, or check out the list of recent builds.

@jakob jakob added the needs-testing label Feb 16, 2018

@qwesda

This comment has been minimized.

qwesda commented Feb 27, 2018

Quick note: the notifications style for postico must be set to "Alerts" - mine was set to "Banners" and it took me a while to figure out why nothing was happening.

@jakob

This comment has been minimized.

Owner

jakob commented Feb 27, 2018

@qwesda Thanks for the feedback, this is a bug -- I have the default setting ("Banners") and it works.

What version of macOS are you on?

@qwesda

This comment has been minimized.

qwesda commented Feb 27, 2018

oh ... well then here are my stats: MacOS 10.13.3 / Postgres 10.2, "do not disturb" is not enabled.

@jakob

This comment has been minimized.

Owner

jakob commented Feb 27, 2018

Could it be that you had multiple copies of Postico running? I've seen issues with user notifications when multiple copies of an app were active...

@qwesda

This comment has been minimized.

qwesda commented Feb 27, 2018

nope, only the test build was running (also re-tested just now).
Rebooting also didn't help.

@jakob

This comment has been minimized.

Owner

jakob commented Mar 9, 2018

OK, so I discovered the cause of the issue. The problem was that for some reason, the invisible "query done" notification was preventing the "notify" notification from showing -- but only on 10.13.

I've now changed how query done notifications work (see #342), and now the NOTIFY messages should show up.

Thanks a lot for the feedback @qwesda!

Build 2458 or later should now support LISTEN / NOTIFY as expected!
https://eggerapps.at/postico/builds/

@qwesda

This comment has been minimized.

qwesda commented Mar 9, 2018

works as expected now. Tested it directly with (NOTIFY a, 'hi';) and with a NOTIFY in a plpgsql function.

But I think a feature like this would need a dedicated interface. As soon as you have multiple NOTIFY per minute having only the system notifications as a log will be awkward to use. I'm thinking of using LISTEN/NOTIFY for a cache invalidation service and hooking into the message pipe with Postico would be great, but I would need a window/message log for it to be useful.

Maybe a separate window where you can:

  • specify the message pipe name
  • start/stop the listening
  • see a log of the messages
  • toggle system notifications

Executing LISTEN a;could automatically open the message log window. The log window should also have its own connection, so it doesn't die when I close the wrong tab ...

@jakob

This comment has been minimized.

Owner

jakob commented Mar 12, 2018

Thanks. Those are good points. An interface like that would be much more useful than just displaying system notifications.

However, this would take a lot more effort than I want to put into this feature. I actually think that this would be enough functionality to build a standalone app...

So I think I'm going to leave the feature as it is, knowing that it's not quite there for "real work", but it's good enough to play a bit with LISTEN / NOTIFY. It's also unlikely to interfere, since you need to actively start listening.

For your use case, maybe you can use a simple python script like this:
listen.py.txt

Anyway, thanks for your feedback!

@jakob jakob closed this Apr 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment