PaulGilmartin / django-pgpubsub

A distributed task processing framework for Django built on top of the Postgres NOTIFY/LISTEN protocol.
Other
245 stars 12 forks source link

Store only notification id in the payload for lockable notifications #76

Open romank0 opened 9 months ago

romank0 commented 9 months ago

This fixes https://github.com/PaulGilmartin/django-pgpubsub/issues/67

Currently for the updated django entity that has an associated TriggerChannel the notification payload is sent via postgres NOTIFY and it contains the old and the new serialized entity states. In the listener the payload that is sent via postgres channel is used only to find the appropriate Notification record from the DB (by comparing the payload text) and then the payload is retrieved from the database record and is actually used.

This sending of the complete payload is suboptimal:

This MR implements sending only the notification ID in the postgres notification for the TriggerChannel that has a persistent notifications enabled.

This implementation keeps the listener backward compatible as in it can still process old notifications sent with a complete payload. That compatiblity should be removed in the followup versions.