fanout / django-eventstream

Server-Sent Events for Django
MIT License
664 stars 88 forks source link

Support ZeroMQ #126

Open bgervan opened 1 year ago

bgervan commented 1 year ago

Pushpin supports ZeroMQ https://pushpin.org/docs/usage/#publishing

It would be great if this package can use zeroMQ between pushpin instances and the server. Maybe the https://github.com/fanout/pypubcontrol is a good base for that. Using for publishing a message is easier to understand, but how the pushpin to server direction can be implemented? The idea is form here: https://pushpin.org/docs/advanced/#subscription-forwarding

jkarneges commented 1 year ago

django-eventstream does use pypubcontrol and it is possible to use ZeroMQ with it.

You'll need to set GRIP_PROXIES instead of GRIP_URL in your settings.py, in order to set special configuration like this:

GRIP_PROXIES = [{
    'control_zmq_uri': 'tcp://localhost:5563',
    'require_subscribers': True
}]

Be sure Pushpin is running before the Django app is started. On start, the Django app will make an RPC call to the specified ZeroMQ address for feature discovery. The require_subscribers option tells the app to send messages using a ZeroMQ PUB socket (instead of PUSH) if supported by Pushpin.