SwampDragon – Build real-time apps with Django
swampdragon.net
swampdragon.net
I'm celebrating my daughters first birthday today so I have to keep it a bit short:
About the serializers: You do need separate serializers from DRF (they are not the same package after all).
As someone pointed out on Github as well, this is depending on Redis 2.8 since it's using Redis pubsub, and I will add this to the documentation.
If you have any questions feel free to email me at: hagstedt at gmail.com. I will try to compile all questions into an FAQ and put it on swampdragon.net.
If you are using ReadTheDocs, one of many default themes would be just fine.
Like, I understand the need to communicate with new sites and docs and a 'project moniker' and so, but wouldn't realtime just be another commit to the main Django base? If not .. why?
My speculation:
I didn't dig much into code but if Swampdragon relies on Redis pub-sub to notice when a result of a query might change and then refetches the query and diffs the result (this is a common strategy I saw among different "real-time" web-frameworks), then depending on the complexity of queries and rate of changes you can put the load on your database. And depending on the fetched result, you can spend more CPU cycles on diffing the results.
* Objects are diffed in the python process before saving the new state. They are diffed with what was loaded from the DB at object initialization time.
https://github.com/jonashagstedt/swampdragon/blob/master/swa...
* Then, the whole object is stored, and the changes are broadcasted. Since the whole object is stored, you can get race conditions if multiple server processes modify it concurrently.
https://github.com/jonashagstedt/swampdragon/blob/master/swa...
* Messages are sent from Python to Redis Pub/Sub channels, and received by Python again. If the Python process has (Websocket) subscribers for the channel, messages are delivered. The indirection over Redis allows having multiple Python processes.
Tornado deals with the websockets, but everything else is Django.
You could easily add this to an existing Django project. It's also using Django settings, etc.
You are right about the potential race conditions using the self publishing model, but you don't have to use the self publishing model though, it works just as well using the routers + serializers.