Skip to content

nops-io/nops-kafka

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nops-kafka

Package contains helpers to consume and produce using Kafka.

Installation

pip install nops-kafka

Usage:

Producing and consuming. Consumer returns iterator.

from nops_kafka import Producer, Consumer

bootstrap_servers = "kafka.kafka.svc.cluster.local:9092"

producer = Producer(bootstrap_servers=bootstrap_servers)
producer.send("topicname", value={"any": "payload"}, headers={"and": "any_headers"})
producer.flush()

# For consuming single or multiple topics at once
consumer = Consumer(bootstrap_servers=bootstrap_servers, group_id="KAFKA_CONSUMER_GROUP_ID", auto_offset_reset="latest")
consumer.subscribe(["topicname"])

event = next(consumer.receive())
print(event)

for event in consumer.receive():
    yield event

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published