Skip to content
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

Listen/Notify support #12

Closed
deem0n opened this issue Sep 30, 2015 · 5 comments
Closed

Listen/Notify support #12

deem0n opened this issue Sep 30, 2015 · 5 comments

Comments

@deem0n
Copy link

deem0n commented Sep 30, 2015

Hello,

Is it possible to add support for http://www.postgresql.org/docs/9.4/static/sql-listen.html ?
The use case might be:

  1. Lua/moon calls LISTEN in PostgreSQL session and register async callback written in Lua/moon
  2. Lua/Moon callback is asynchronously called as result of NOTIFY inside PostgreSQL
  3. Callback process the data, and send changes to the client via WebSocket

Thank you !

@mkozjak
Copy link

mkozjak commented Oct 28, 2016

Since there's nothing in docs, but 1.5.0 changelog says it's there, is this now supported?

@leafo
Copy link
Owner

leafo commented Oct 28, 2016

It should, here's the code: https://github.com/leafo/pgmoon/pull/28/files

Docs are indeed missing though.

@mkozjak
Copy link

mkozjak commented Oct 28, 2016

Nice!

@AdrienPensart
Copy link

Have you got a little example ? Because I can't get to have only one connection to postgresql (I can see it in pg_top) when I open multiple tab of my websocket html...and setkeepalive just mess up the socket...

@valpackett
Copy link

@AdrienPensart you can use a background worker (init_worker_by_lua_block { ngx.timer.at(0, your_function) }) and something like lua-resty-worker-events to communicate from that worker to your websocket handler.

@leafo leafo closed this as completed Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants