Kafka adapter for FastMesh — KafkaSource and KafkaSink via aiokafka
Project description
fastmesh-kafka
Kafka adapter for FastMesh —
KafkaSource and KafkaSink via aiokafka.
Install
pip install fastmesh-kafka
Usage
from fastmesh import Bus
from fastmesh_kafka import KafkaSource, KafkaSink
source = KafkaSource(
topics=["orders"],
bootstrap_servers="localhost:9092",
group_id="pipeline-consumer",
auto_offset_reset="earliest",
)
sink = KafkaSink(
topic="processed-orders",
bootstrap_servers="localhost:9092",
)
await Bus().source(source).sink(sink).run()
KafkaSource
| Parameter | Default | Description |
|---|---|---|
topics |
(required) | List of topic names |
bootstrap_servers |
"localhost:9092" |
Broker addresses |
group_id |
"fastmesh" |
Consumer group ID |
auto_offset_reset |
"latest" |
"earliest" or "latest" |
enable_auto_commit |
True |
Auto-commit offsets |
value_deserializer |
JSON decode | (bytes) -> dict |
Each Kafka record → one Message. Kafka metadata in msg.metadata:
kafka_topic, kafka_partition, kafka_offset, kafka_key (if present).
KafkaSink
| Parameter | Default | Description |
|---|---|---|
topic |
(required) | Target topic name |
bootstrap_servers |
"localhost:9092" |
Broker addresses |
key_fn |
msg.id.encode() |
(Message) -> bytes | None |
value_serializer |
JSON encode | (dict) -> bytes |
The producer is lazily initialized on first send() and reused. Call
await sink.stop() on shutdown to flush and close.
With FastMesh plugins
from fastmesh.plugins.retry import Retry
from fastmesh.plugins.dlq import DeadLetterQueue, MemoryDLQStore
store = MemoryDLQStore()
bus = Bus().source(
KafkaSource(topics=["orders"], bootstrap_servers="kafka:9092")
).sink(
DeadLetterQueue(
Retry(KafkaSink("processed", bootstrap_servers="kafka:9092"), max_retries=3),
store=store,
)
)
Requirements
- Python 3.11+
- fastmesh >= 0.2
- aiokafka >= 0.11
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastmesh_kafka-0.1.0.tar.gz.
File metadata
- Download URL: fastmesh_kafka-0.1.0.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2ddb07715ff7f8b1ce96aeedd2122e0a8679d0db3a73ddf67ceeeba245914b5a
|
|
| MD5 |
4c688e9f9c75a3864dd5f6fab6f33881
|
|
| BLAKE2b-256 |
aa28869b64903e2e1daecc927d61216578dd2f5920db2e5f25c5cd3af10b873b
|
File details
Details for the file fastmesh_kafka-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fastmesh_kafka-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3584283f75a1c89694ece20932efc5f0f3ea526daba0ca050d32070b56507731
|
|
| MD5 |
25aaf3461c2be295b1c8354c81663d30
|
|
| BLAKE2b-256 |
fac7677bbe55c6b42770f64b79e7dffb50f0e2ea901e1b656a69de90e2644698
|