Skip to main content

Kafka

Project description

vahfka

The vahfka library simplifies Kafka interaction by providing convenient abstractions for both producing and consuming messages. It seamlessly integrates with the kafka-python library and offers additional features for asynchronous message sending and context management.

Installation

You can install the vahfka library using pip:

pip install vahfka Usage

Initializing the Kafka Producer: from vahfka import KafkaProducerWithCallbacks

Create a KafkaProducerWithCallbacks instance

kafka_producer = KafkaProducerWithCallbacks(bootstrap_servers='localhost:9092') Sending Messages: Synchronous Message Sending:

Send a message synchronously

kafka_producer.send_message(topic='example_topic', message={'key': 'value'}) Asynchronous Message Sending:

Send a message asynchronously

kafka_producer.send_message_async(topic='example_topic', message={'key': 'value'}) Kafka Consumer Wrapper: from vahfka import KafkaConsumerWrapper

Create a KafkaConsumerWrapper instance

kafka_consumer = KafkaConsumerWrapper( bootstrap_servers='localhost:9092', group_id='my-group', topics=['example_topic'] ) Consuming Messages:

Consume messages from Kafka topic

messages = kafka_consumer.consume_messages() print(messages) Context Management:

Use the KafkaProducerWithCallbacks as a context manager

with KafkaProducerWithCallbacks(bootstrap_servers='localhost:9092') as producer: producer.send_message(topic='example_topic', message={'key': 'value'}) Example

from vahfka import KafkaProducerWithCallbacks, KafkaConsumerWrapper

Initialize KafkaProducerWithCallbacks and KafkaConsumerWrapper instances

kafka_producer = KafkaProducerWithCallbacks(bootstrap_servers='localhost:9092') kafka_consumer = KafkaConsumerWrapper( bootstrap_servers='localhost:9092', group_id='my-group', topics=['example_topic'] )

Send a message

kafka_producer.send_message(topic='example_topic', message={'key': 'value'})

Consume messages

messages = kafka_consumer.consume_messages() print(messages) For questions, issues, or contributions, please visit thevahfka

The vahfka library simplifies Kafka interaction by providing convenient abstractions for both producing and consuming messages. It seamlessly integrates with the kafka-python library and offers additional features for asynchronous message sending and context management.

Installation

You can install the vahfka library using pip:

pip install vahfka Usage

Initializing the Kafka Producer: from vahfka import KafkaProducerWithCallbacks

Create a KafkaProducerWithCallbacks instance

kafka_producer = KafkaProducerWithCallbacks(bootstrap_servers='localhost:9092') Sending Messages: Synchronous Message Sending:

Send a message synchronously

kafka_producer.send_message(topic='example_topic', message={'key': 'value'}) Asynchronous Message Sending:

Send a message asynchronously

kafka_producer.send_message_async(topic='example_topic', message={'key': 'value'}) Kafka Consumer Wrapper: from vahfka import KafkaConsumerWrapper

Create a KafkaConsumerWrapper instance

kafka_consumer = KafkaConsumerWrapper( bootstrap_servers='localhost:9092', group_id='my-group', topics=['example_topic'] ) Consuming Messages:

Consume messages from Kafka topic

messages = kafka_consumer.consume_messages() print(messages) Context Management:

Use the KafkaProducerWithCallbacks as a context manager

with KafkaProducerWithCallbacks(bootstrap_servers='localhost:9092') as producer: producer.send_message(topic='example_topic', message={'key': 'value'}) Example

from vahfka import KafkaProducerWithCallbacks, KafkaConsumerWrapper

Initialize KafkaProducerWithCallbacks and KafkaConsumerWrapper instances

kafka_producer = KafkaProducerWithCallbacks(bootstrap_servers='localhost:9092') kafka_consumer = KafkaConsumerWrapper( bootstrap_servers='localhost:9092', group_id='my-group', topics=['example_topic'] )

Send a message

kafka_producer.send_message(topic='example_topic', message={'key': 'value'})

Consume messages

messages = kafka_consumer.consume_messages() print(messages) For questions, issues, or contributions, please visit the

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

vahfka-0.2.tar.gz (2.3 kB view details)

Uploaded Source

File details

Details for the file vahfka-0.2.tar.gz.

File metadata

  • Download URL: vahfka-0.2.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.5

File hashes

Hashes for vahfka-0.2.tar.gz
Algorithm Hash digest
SHA256 6f2cfcee7051959b91537312d739bb81f08cfaab9b5caad65be2723eae2f7895
MD5 724185aef43d8cb0a75ae919aa4980cb
BLAKE2b-256 1b22f0cfceab5eea66741413f2f66213b7732efd17f3ba42c7f79f575661643a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page