Kafka Channels backend
Project description
Channels 🔗 Kafka
channels-kafka
A Django Channels channel layer that uses Kafka as its backing store.
Explore the docs »
Report Bug
·
Request Feature
Table of Contents
About The Project
Provides channel layer for django channels using kafka
Built With
Getting Started
To work with django channels using this channel layer you will need to have working kafka cluster. As of time of writing, this library was only tested on Kafka with Kraft Mode.
Prerequisites
channels-kafka should be able to be installed using any package manager of your choice, although ci tests use uv
Installation
- uv
uv add channels-kafka
- pip
pip install channels-kafka
Usage
Assuming that you already have a working django-channels app using any other layer, the only thing you would need to do in your django code is to change CHANNEL_LAYERS setting in your django to use this backend with all releavant configuration.
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_kafka.core.KafkaChannelLayer",
"CONFIG": {
"hosts": os.getenv("KAFKA_HOSTS", "localhost:9092").split(","),
"client_id": os.getenv("KAFKA_CLIENT_ID", socket.gethostname()),
"topic": os.getenv("KAFKA_CLIENT_ID", "channels-kafka"),
"group_id": os.getenv("KAFKA_GROUP_ID", "channels-kafka-group"),
},
},
}
As for kafka broker, you would need to:
- create desired topic
- set offsets.topic.replication.factor to 1 since channels documentation says you should be ok with some messages not being delivered to increase throughput
- set max.in.flight.requests.per.connection to 1 to ensure that messages are delivered in order
Both settings can be scoped only to created topic aswell
Contributing
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Testing
Check all caps constants in https://github.com/PawelKawula/channels-kafka/blob/master/tests/test_core.py to see which env variables you need to provide to run tests using your kafka cluster and then run
pytest
Top contributors:
License
Distributed under the MIT license. See LICENSE for more information.
Contact
Project Link: https://github.com/PawelKawula/channels-kafka
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file channels_kafka-0.1.1.tar.gz.
File metadata
- Download URL: channels_kafka-0.1.1.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1109d6789d5ab48135e7c23c17d24f18c2df6b6676a2015002ec71a52b46931f
|
|
| MD5 |
408dff4096c5cf280ff0ec56d63d0d74
|
|
| BLAKE2b-256 |
f954135e0917ddf3fc4bb942b5b123fa211b24d9bc21fb896f19d83fd586d002
|
File details
Details for the file channels_kafka-0.1.1-py3-none-any.whl.
File metadata
- Download URL: channels_kafka-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
625688c6c9f8cd7f5c78124a3b86015f0190816d9c4c18163e073165ee17dcd8
|
|
| MD5 |
949999ad1c4b9d79d8b30fdbe7050260
|
|
| BLAKE2b-256 |
3ce63391721c21da8d66607ea83e92395c7913cd4cb899cec920796e1f28cd8a
|