5 ms·
I'm the GoodJob author. Here's the class that is responsible for implementing Postgres's LISTEN/NOTIFY functionality in GoodJob: https://github.com/bensheldon/
by sideofbacon 3y ago
I'm the GoodJob author. Here's the class that is responsible for implementing Postgres's LISTEN/NOTIFY functionality in GoodJob:
https://github.com/bensheldon/good_job/blob/10e9d9b714a668dc37572d0e38302a5380555858/lib/good_job/notifier.rb https://github.com/bensheldon/good_job/blob/10e9d9b714a668dc...
That's heavily inspired by Rail's Action Cable (websockets) Adapter for Postgres, which is a bit simpler and easier to understand:
https://github.com/rails/rails/blob/be287ac0d5000e667510faba0dbf28ffdb7c5e35/actioncable/lib/action_cable/subscription_adapter/postgresql.rb https://github.com/rails/rails/blob/be287ac0d5000e667510faba...
Briefly, it spins up a background thread with a dedicated database connection and makes a blocking Postgres LISTEN query until results are returned, and then it forwards the result to other subscribing objects.
- comboy 3y agoexcited claps