Skip to main content

EVKafka framework. Handle kafka events easy

Project description

evkafka

EVKafka is a small framework for building event driven microservices with Apache Kafka and Python.

Installation

 $ pip install evkafka

Basic consumer

from evkafka import EVKafkaApp


config = {
    "topics": ["topic"],
    "bootstrap_servers": "kafka:9092",
    "group_id": "test",
}

app = EVKafkaApp(config=config)


@app.event("FooEvent")
async def foo_handler(event: dict) -> None:
    print(event)


if __name__ == "__main__":
    app.run()

Basic producer

import asyncio
from evkafka import EVKafkaProducer


async def produce(event: dict, event_type: str):
    config = {
        "topic": "topic", 
        "bootstrap_servers": "kafka:9092"
    }

    async with EVKafkaProducer(config) as producer:
        await producer.send_event(
            event=event,
            event_type=event_type,
        )

if __name__ == "__main__":
    asyncio.run(produce({"data": "value"}, "FooEvent"))

More details can be found in the documentation

Status

The framework is in alpha.

License

This project is licensed under the terms of the MIT license.

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

evkafka-0.3.0.tar.gz (16.5 kB view hashes)

Uploaded Source

Built Distribution

evkafka-0.3.0-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

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