Hey Richard, in the time between when this post was submitted and when it was approved for the mailing list, I made some progress reading through the existing implementation. There are some notes on the Twitter thread: https://twitter.com/seanlinsley/status/678654835982524416
The most important point is that the current code seems to create a new Redis connection for every websocket. It seems like Redis can handle that (the default max is 10k), but Postgres definitely can’t. My gist worked around that by creating a single thread to listen for new events, and trigger notifications to everyone that’s listening. It’d be quite difficult to keep the current approach and also support Postgres.
Thanks for the link to your repo. Reading through, I discovered that there’s a
raw_connection method! Much better than accessing the instance variable like I was doing ^^’
I also refactored my gist, turning the one 20 line method into two 10 line methods. Though I haven’t actually tested that it still works ¯_(ツ)_/¯