kafka
#
- class platypush.message.event.kafka.KafkaMessageEvent(*args, msg: str | list | dict, topic: str, host: str, port: int, partition: int, offset: int, timestamp: float, key: str | None = None, headers: Iterable | None = None, **kwargs)[source]#
Bases:
Event
Kafka message event object. Fired when
platypush.backend.kafka
receives a new event.- __init__(*args, msg: str | list | dict, topic: str, host: str, port: int, partition: int, offset: int, timestamp: float, key: str | None = None, headers: Iterable | None = None, **kwargs)[source]#
- Parameters:
msg – Received message. If the message is a JSON string, it will be returned as a dict or list. If it’s a binary blob, it will be returned as a base64-encoded string.
topic – Topic where the message was received.
host – Host where the message was received.
port – Port where the message was received.
partition – Partition where the message was received.
offset – Offset of the message.
timestamp – Timestamp of the message.
key – Optional message key.
headers – Optional message headers.
- as_dict()#
Converts the event into a dictionary
- classmethod build(msg)#
Builds an event message from a JSON UTF-8 string/bytearray, a dictionary, or another Event
- matches_condition(condition)#
If the event matches an event condition, it will return an EventMatchResult :param condition: The platypush.event.hook.EventCondition object
- classmethod parse(msg)#
Parse a generic message into a key-value dictionary
- Parameters:
msg – Original message. It can be a dictionary, a Message, or a string/bytearray, as long as it’s valid UTF-8 JSON
- classmethod to_dict(msg)#
Converts a Message object into a dictionary
- Parameters:
msg – Message object