https://github.com/PostHog/posthog/pull/3280
ee/kafka_client/client.py
self.max = max
        self.n = 0
        self.topic = topic
    def __iter__(self):
        return self
    def __next__(self):
        if self.n <= self.max:
            self.n += 1
            return f"message {self.n} from {self.topic} topic"
        else:
            raise StopIteration
    def seek_to_beginning(self):
        return
    def seek_to_end(self):
        return
    def subscribe(self, _):
        return
class _KafkaProducer:
    def __init__(self, test=TEST):
        if test:
            self.producer = TestKafkaProducer()
        elif KAFKA_BASE64_KEYS:
            self.producer = helper.get_kafka_producer(retries=KAFKA_PRODUCER_RETRIES, value_serializer=lambda d: d)
        else:
            self.producer = KP(retries=KAFKA_PRODUCER_RETRIES, bootstrap_servers=KAFKA_HOSTS)
    @staticmethod
    def json_serializer(d):
        b = json.dumps(d).encode("utf-8")
        return b
    def produce(self, topic: str, data: Any, key: Any = None, value_serializer: Optional[Callable[[Any], Any]] = None):