Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/franciscoda/channels_zmq

ZeroMQ Channels layer implementation
https://github.com/franciscoda/channels_zmq

channels django django-channels zeromq

Last synced: 10 days ago
JSON representation

ZeroMQ Channels layer implementation

Awesome Lists containing this project

README

        

# channels_zmq
[![Tests status](https://github.com/FranciscoDA/channels_zmq/actions/workflows/tests.yml/badge.svg)](https://github.com/FranciscoDA/channels_zmq/actions/workflows/tests.yml)
[![PyPI](https://img.shields.io/pypi/v/channels-zmq)](https://pypi.org/project/channels-zmq/)

A channel layer implementation using ZeroMQ PUB-SUB topology.

### Installation

Install package from PyPI:
```sh
pip install channels-zmq
```

### Usage

Configure the layer in your Django settings file. You can choose one of the two implementations described below:

##### Embedded layer

```py
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_zmq.core.EmbeddedZmqChannelLayer",
"CONFIG": {
"pub_socket_address": "",
"capacity": 100,
"expiry": 60,
},
},
}
```

The embedded layer binds a ZeroMQ PUB socket inside the process that calls `send` or `group_send`.
Consumers will connect their SUB sockets to the same socket.

While this is a very lightweight implementation, it only allows a single process to call `send` and `group_send` with
the same layer.

If you need to send data created through other processes, you should create a different layer or use the [dedicated layer](#dedicated-layer).
```
+----------------+
|PRODUCER PROCESS|
|----------------|
| PUB SOCKET |
+----------------+
^ ^ ^
| | |
+-----------+ | +----------+
| | |
+------------+ +------------+ +------------+
| SUB SOCKET | | SUB SOCKET | | SUB SOCKET |
|------------| |------------| |------------|
| CONSUMER 1 | | CONSUMER 2 | | CONSUMER 3 |
+------------+ +------------+ +------------+
```

##### Dedicated layer

```py
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_zmq.core.DedicatedZmqChannelLayer",
"CONFIG": {
"pull_socket_address": "",
"pub_socket_address": "