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
File details
Details for the file kafka-python-dataclasses-2022.4.22.2.tar.gz
.
File metadata
- Download URL: kafka-python-dataclasses-2022.4.22.2.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f140feb605b84f233a83452baffa9163a2c34885b589841656975575ac1797 |
|
MD5 | 6e2db88eb32b444bc7e48bc1906a423f |
|
BLAKE2b-256 | da0da03952bd32b1e2b2565909bd3a1dc3f5ed4bdb84d7049e21f93b4a885cc5 |
File details
Details for the file kafka_python_dataclasses-2022.4.22.2-py3-none-any.whl
.
File metadata
- Download URL: kafka_python_dataclasses-2022.4.22.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 610640164d742faa4dfc18803e27f95a24bbb40ef831590a5b3ba39feea070dc |
|
MD5 | 8924923aab59c147f2ae9b79723ac37f |
|
BLAKE2b-256 | 5ae8dfd819f7ed3085c9ea4b38371a2a3b7745d7c795bb657461d188a6b48111 |