platypush.backend.kafka

class platypush.backend.kafka.KafkaBackend(server='localhost:9092', topic='platypush', **kwargs)[source]

Backend to interact with an Apache Kafka (https://kafka.apache.org/) streaming platform, send and receive messages.

Requires:

  • kafka (pip install kafka-python)
__init__(server='localhost:9092', topic='platypush', **kwargs)[source]
Parameters:
  • server (str) – Kafka server name or address + port (default: localhost:9092)
  • topic (str) – (Prefix) topic to listen to (default: platypush). The Platypush device_id (by default the hostname) will be appended to the topic (the real topic name will e.g. be “platypush.my_rpi”)
on_stop()[source]

Callback invoked when the process stops

run()[source]

Starts the backend thread. To be implemented in the derived classes if the loop method isn’t defined.

send_message(msg)[source]

Sends a platypush.message.Message to a node. To be implemented in the derived classes. By default, if the Redis backend is configured then it will try to deliver the message to other consumers through the configured Redis main queue.

Parameters:
  • msg – The message to send
  • queue_name – Send the message on a specific queue (default: the queue_name configured on the Redis backend)