Skip to content

Instantly share code, notes, and snippets.

Waldecir Faria wfaria

Block or report user

Report or block wfaria

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@wfaria
wfaria / HeartbeatProducer.py
Last active Aug 23, 2018
Kafka Producer example for Medium article
View HeartbeatProducer.py
import time
from time import gmtime, strftime
from kafka import KafkaProducer
def publish_message(producer_instance, topic_name, key, value):
try:
key_bytes = bytes(key, encoding='utf-8')
value_bytes = bytes(value, encoding='utf-8')
producer_instance.send(topic_name, key=key_bytes, value=value_bytes)
producer_instance.flush()
You can’t perform that action at this time.