You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
augustosamame
changed the title
Location of listener class so it will listen forever
Location of Listener class so it will listen forever
May 12, 2021
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.
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: