-
Notifications
You must be signed in to change notification settings - Fork 9
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
Location of Listener class so it will listen forever #20
Comments
That's a good question. I've only ever used this as part of a separate, long-running process that would run alongside your web process and worker for sidekiq, etc. For example this gem contains a rake task to run a separate process that will listen to a PG table and enqueue jobs to Sidekiq https:/ezcater/sidekiq_publisher/blob/master/lib/sidekiq_publisher/runner.rb#L19-L28. It may be possible for you to run the Listener in a Thread in one of your existing processes so that it does not block, but I have not attempted this. If you went with this approach you'd have to consider error handling to ensure that the Listener keeps running and that errors from it do not take down the process. |
I'd like to use this gem to handle PG NOTIFYs from another project's db. Seems like an ideal use case. However, I don't understand where I should run the Listener class so it will run forever in my Rails project.
If I run it on demand, with a timeout, it defeats the purpose of "listening" to the PostgreSQL DB's notifys.
I'm using Puma, which is multithreaded so should I just place the Listener Class in an initializer and it will block a single worker? Should I use sidekiq instead?
Thanks in advance on any clarity you can provide.
The text was updated successfully, but these errors were encountered: