Add entity_id as key for kafka message (#121519)

Co-authored-by: Aaron Bach <bachya1208@gmail.com>
This commit is contained in:
Leonard Sperry 2024-07-09 02:44:49 -04:00 committed by GitHub
parent 48d9df74ed
commit cfabb778dd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -141,7 +141,8 @@ class KafkaManager:
async def write(self, event: Event[EventStateChangedData]) -> None:
"""Write a binary payload to Kafka."""
key = event.data["entity_id"].encode("utf-8")
payload = self._encode_event(event)
if payload:
await self._producer.send_and_wait(self._topic, payload)
await self._producer.send_and_wait(self._topic, payload, key)