kaflow is a simple framework that allows you to build Kafka streams processing aplications in Python with ease.
Some of the features offered by kaflow:
- Dependency Injection system inspired by FastAPI and xpresso, and backed by di.
- Automatic deserialization of incoming messages and serialization of outgoing messages. Supports popular formats like
JSON,AvroorProtobuf. - Message validation thanks to pydantic.
Python 3.8+
pip install kaflowfrom kaflow import Json, Kaflow
from pydantic import BaseModel
class UserClick(BaseModel):
user_id: int
url: str
timestamp: int
app = Kaflow(name="AwesomeKakfaApp", brokers="localhost:9092")
@app.consume(topic="user_clicks", sink_topics=("user_clicks_json",))
async def consume_user_clicks(message: Json[UserClick]) -> Json[UserClick]:
print("user click", message)
return message
app.run()