Skip to main content

Add a short description here!

Project description

Project generated with PyScaffold

kafka-python-dataclasses

Structured messages for your kafka projects

Kafka is a really complex library and dealing with bytes can be taxing. Use these wonderful structured Kafka classes instead!

Basic consuming:

from dataclasses import dataclass
from kafka_dataclasses import StructuredKafkaConsumer


@dataclass
class MyKafkaMessage:
   value: str


for message in StructuredKafkaConsumer(['my_topic']):
   assert type(message) == MyKafkaMessage

Basic producing:

from dataclasses import dataclass
from kafka_dataclasses import StructuredKafkaProducer


@dataclass
class MyKafkaMessage:
   value: str


StructuredKafkaProducer().send('my_topic', MyKafkaMessage("Hello, world!"))

This works on deeply nested dataclasses as well! In theory it will also work on attrs classes, since the unstructuring library, cattrs, supports attrs out of the box.

Note

This project has been set up using PyScaffold 4.2.1. For details and usage information on PyScaffold see https://pyscaffold.org/.

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

kafka-python-dataclasses-2022.4.22.3.tar.gz (19.7 kB view hashes)

Uploaded Source

Built Distribution

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