Coverage for portality/events/kafka_producer.py: 0%
8 statements
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-22 15:59 +0100
« prev ^ index » next coverage.py v6.4.2, created at 2022-07-22 15:59 +0100
1import json
2from kafka import KafkaProducer
4from portality.core import app as doajapp
5bootstrap_server = doajapp.config.get("KAFKA_BOOTSTRAP_SERVER")
7producer = KafkaProducer(bootstrap_servers=bootstrap_server, value_serializer=lambda v: json.dumps(v).encode('utf-8'))
10def send_event(event):
11 future = producer.send('events', value=event.serialise())
12 future.get(timeout=60)