djangochannelsrestframework
djangochannelsrestframework copied to clipboard
Investigate using PostgreSQL NOTIFY and commit hooks
Is your feature request related to a problem? Please describe. Currently this lib uses Django Signals to detect changes however Django does not send these events if you do bulk updates or raw SQL operations and if you have other clients connecting to the database making changes you also do not get any events.
Describe the solution you'd like PostgreSQL support the concept of NOTIFY and LISTEN, since commit hocks can send NOTIFY messages it would be possible to have PG automatically inform all LISTENs of db changes regardless of were the changes came from.
I would like to investigate a little more how NOTIFY and LISTEN work in PG and how easy/hard it would be to add something to Django's DB manager that automatically adds migrations for ObservableModel
classes to trigger the NOTIFY on commit.
As a first pass it could be interesting to implement a PG packed change channels layer that uses the LISTEN and NOTIFY api this could be an interesting option for people who do not want to deploy an additional redis.