Skip to content

Asynchronous wrappers around kafka-python's Producer and Consumer classes.

License

Notifications You must be signed in to change notification settings

mpol1t/kafkoroutine

Repository files navigation

codecov GitHub PyPI PyPI - Python Version

kafkoroutine

This repository offers Python-based asynchronous wrappers around kafka-python's Producer and Consumer, bridging them seamlessly with Python's asyncio.

Prerequisites

  • Python 3.7 or later
  • A running Kafka instance (for actual message passing)

Getting Started

Follow these instructions to integrate the asynchronous Kafka components in your asyncio-based Python project.

Installation

Install kafkoroutine using pip:

pip install kafkoroutine

Please note: this project requires Python 3.7 or later and is built upon the kafka-python library.

Usage

AsyncKafkaConsumer

from kafkoroutine.consumer import AsyncKafkaConsumer

async with AsyncKafkaConsumer(topics=topics, bootstrap_servers='localhost:9092', executor=None) as consumer:
    async for message in consumer:
        print(f"Received: {message.value.decode('utf-8')}")

AsyncKafkaProducer

from kafkoroutine.producer import AsyncKafkaProducer

async with AsyncKafkaProducer(bootstrap_servers='localhost:9092', executor=None) as producer:
    for msg in messages:
        await producer.send(topic, msg)

Built With

  • Poetry - Packaging and dependency management
  • asyncio - Asynchronous I/O, event loop, and coroutines used for the implementation.
  • kafka-python - The Python client for Apache Kafka upon which these asynchronous wrappers are built.

License

This project follows the guidelines of the MIT License.

About

Asynchronous wrappers around kafka-python's Producer and Consumer classes.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages