A Django app to store an event and publish the event to Kafka
Project description
Create an event from Django ORM object model, store the event into the database and also publish it into Kafka cluster.
Quick start
Install the package:
pip install django-kafka-event-log
In your project’s settings.py, include the app and add credentials for Kafka:
INSTALLED_APPS = [ ... 'events', ] KAFKA_GROUP = 'KAFKA_GROUP' KAFKA_BOOTSTRAP_SERVERS = 'KAFKA_BOOTSTRAP_SERVERS' KAFKA_SECURITY_PROTOCOL = 'KAFKA_SECURITY_PROTOCOL' KAFKA_SASL_MECHANISMS = 'KAFKA_SASL_MECHANISMS' KAFKA_SASL_USERNAME = 'KAFKA_SASL_USERNAME' KAFKA_SASL_PASSWORD = 'KAFKA_SASL_PASSWORD'
Note: the credential should be read from environment variables.
This application has only 1 interface; it is PublishKafkaEventUtil. Given myapp is where the model object locates, MyModelSerializer is the data presenter, we can call the Util like this:
from events.utils import PublishKafkaEventUtil from myapp.serializers.mymodel_serializer import MyModelSerializer PublishKafkaEventUtil.call( event_name='Created', model_object=model_obj, serializer=ModelSerializer, metadata={'purpose': 'testing'}, )
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for django-kafka-event-log-0.1.5.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26af845e1e6ecedaec7d508018c35bbba8dd964e1c897eaf55f3b951c7dcd2f7 |
|
MD5 | 9dcaca2ce4831608e48e655598ea5523 |
|
BLAKE2b-256 | cf0b06281f98812b5a5fb2bcd3a49bf7f3bd529f768b02dfb4f14b6a61c7939c |