A wrapper for confluent-kafka producer and consumer
Project description
kafka-client-decorator
A wrapper for kafka producer and consumer that can be used as decorator for a function which can keep consuming data, process this data and broadcast it to next topics/queues.
Installation
pip install kafka-client-decorator
Usage
Define your function how you want to process the data and then decorate it.
from kafka-client-decorator import KafkaClient
@KafkaClient(bootstrap_servers, security_protocol, sasl_username, sasl_password).consumer_producer(consumer_from_topic='my-topic-1', group_id='pdf', produce_to_topic=['my-topic-2'])
def process_data(data = None):
# Call your driver modules here to process the data
result = Driver(data)
return result
NOTE: If you want the your driver result to be pushed to next topic/queue, you can simply pass produce_to_topic as arg in decorator 'consumer_prodcuer' method. NOTE: If your kafka broker does not uses SASL or SSL protocol, no need to pass 'sasl_username' and 'sasl_password'.
To only produce to topic(s) -
from kafka-client-decorator import ClientProducer
producer = ClientProducer(bootstrap_servers, security_protocol, sasl_username, sasl_password)
prodcuer.produce_to_broker(data, topic_name)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for kafka-client-decorator-1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33505d2920074631a8c2b54594d62ad687ffdc2557497fbfb829365766a90727 |
|
MD5 | ff973c226ee2fbebde1da6025f5f885b |
|
BLAKE2b-256 | 6026afa99018ae7556a6950501bd97a936a1fdc9eed571bd82b153fcd14668f3 |