Add a short description here!
Project description
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for kafka-python-dataclasses-2022.4.22.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c5734fedd8c559abfcd2e1272ab8e95c1f7a1faa2f9b87147c03d4d7dede8ba |
|
MD5 | dbe8521092d9593ea453f4467048e5e3 |
|
BLAKE2b-256 | ecfc504d87956732fd4aaa649d33c7beef9fb7749cd71cf99187d0cbb5de4eb4 |
Close
Hashes for kafka_python_dataclasses-2022.4.22.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 941d939bae46f8fe12ad40c6c8927ef92f4ea2ff23f701c828b8fcb453c6b61d |
|
MD5 | 5ebb18e0dd970ca7836383d43e538828 |
|
BLAKE2b-256 | 0b79975712c232822f328f9c7f01683568497b1cc0360fa1282cbd6b6fbed5a4 |