Skip to main content

A Django app to store an event and publish the event to Kafka

Project description

Store an event and publish the event to Kafka

Quick start

  1. Install package:

    pip install django-kafka-event-log
  2. Add “events” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'events',
    ]
  3. Set up Kafka credential in “settings.py” like this:

    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'
  4. Store and send event:

    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'},
    )

Author: Diag

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

django-kafka-event-log-0.1.3.tar.gz (6.5 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page