Skip to main content

kaflow

Kafka streams topic processing in Python.

Test


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, Avro or Protobuf.
  • Message validation thanks to pydantic.

Requirements

Python 3.8+

Installation

pip install kaflow

Example

from kaflow import (
    FromHeader,
    FromKey,
    FromValue,
    Json,
    Kaflow,
    Message,
    MessageOffset,
    MessagePartition,
    MessageTimestamp,
    String,
)
from pydantic import BaseModel


class UserClick(BaseModel):
    user_id: int
    url: str
    timestamp: int


class Key(BaseModel):
    environment: str


app = Kaflow(name="AwesomeKakfaApp", brokers="localhost:9092")


@app.consume(topic="user_clicks", sink_topics=["user_clicks_json"])
async def consume_user_clicks(
    message: FromValue[Json[UserClick]],
    key: FromKey[Json[Key]],
    x_correlation_id: FromHeader[String[str]],
    x_request_id: FromHeader[String[str]],
    partition: MessagePartition,
    offset: MessageOffset,
    timestamp: MessageTimestamp,
) -> Message:
    # Do something with the message
    ...

    # Publish to another topic
    return Message(value=b'{"user_clicked": "true"}')


app.run()

Metadata

Release files for kaflow 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kaflow 0.2.2
File Size Uploaded
kaflow-0.2.2.tar.gz 21.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kaflow 0.2.2
File Interpreter ABI Platform
kaflow-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 43.9 kB

Release files / kaflow-0.2.2.tar.gz

Download URL kaflow-0.2.2.tar.gz
Size 21.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a8dd0b54b3ef24260077d4a6509463a13cc5cd1ca14db91569dcde242035409c
BLAKE2b-256 checksum
How to use checksums
8c75da25045f7ff91faa5d52e7d94cdb522bb295bf7ae21d08a4c21557df065e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / kaflow-0.2.2-py3-none-any.whl

Download URL kaflow-0.2.2-py3-none-any.whl
Size 22.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57a21b8a7e25dbc81d5385f7292204afc05dd6399ff982d7926bfde0b57f3aec
BLAKE2b-256 checksum
How to use checksums
56423e50b98b19fda9b34cfe3eca666920e956fc0ef5710dbc5b3fee35043874
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page