This release is a pre-release and may not be stable for production use.
benzene-kafka
Host Benzene Python handlers on Apache Kafka —
a self-hosted consumer and a Kafka-produce outbound client — the same handlers, no rewrite. Depends
only on benzene-core.
pip install benzene-kafka # the binding + testing helpers
pip install "benzene-kafka[kafka]" # + confluent-kafka for the real clients
from benzene.core import application_from, build_application
from benzene.kafka import KafkaConsumerApp, KafkaMessageSender, run_consumer_loop
# Inbound: one record -> one pipeline invocation -> one scope; ack/log, no reply.
definition, _ = build_application(OrdersStartUp)
app = KafkaConsumerApp(application_from(definition))
await run_consumer_loop(app, consumer) # consumer: a confluent_kafka.Consumer
# Outbound: publish to a Kafka topic, Benzene topic carried in the `topic` header.
sender = KafkaMessageSender("orders-events", bootstrap_servers="localhost:9092")
await sender.send_message("orders:created", order, headers={"x-correlation-id": "abc"})
- Consumer — the Benzene topic comes from the record's
topicheader (the cross-port convention); the other Kafka headers are the Benzene headers (UTF-8), the value is the JSON body. One record is one scope; there is no response channel, so the result is acknowledge/log only —run_consumer_loopcommits the offset on success (at-least-once) and leaves a failed record for redelivery. A poison record can never crash the loop. - Outbound —
KafkaMessageSenderimplements thebenzene.core.MessageSenderport overconfluent-kafka(optional extra), forwarding the header dictionary onto the record's Kafka headers so correlation/trace propagation rides across the hop.
The binding is duck-typed against confluent-kafka, so decode, dispatch, and send are exercised in
memory with fakes — no broker, no SDK. Test through benzene.kafka.testing (a native-record builder +
a test host) or the shared harness (create_test_host(StartUp).build_kafka() + send_kafka) — see the
runnable examples/kafka_orders/. Mirrors .NET's Benzene.Kafka.Core, and contributes the
benzene.kafka subpackage to the shared benzene namespace.
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 benzene_kafka-0.1.0b1.tar.gz.
File metadata
- Download URL: benzene_kafka-0.1.0b1.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9693d23452d9a16fb4dc0843a4ec47f3a38e0fc3e75266e0e5ebc20515aa6174
|
|
| MD5 |
2aeb564e2e5ee4a6395e3e68dde9df57
|
|
| BLAKE2b-256 |
c5eb4665c3f3b0a3f27c4e4a2040c2e1cb5e562eb79adcdd9efe30f39f07009e
|
Provenance
The following attestation bundles were made for benzene_kafka-0.1.0b1.tar.gz:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_kafka-0.1.0b1.tar.gz -
Subject digest:
9693d23452d9a16fb4dc0843a4ec47f3a38e0fc3e75266e0e5ebc20515aa6174 - Sigstore transparency entry: 2467246468
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file benzene_kafka-0.1.0b1-py3-none-any.whl.
File metadata
- Download URL: benzene_kafka-0.1.0b1-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
977e9138ce13dc478e720644b6aae2ade3e6f8ab9b554fc2231eff1c5318b288
|
|
| MD5 |
ba10c56729846b1639a0456fcb30cc8a
|
|
| BLAKE2b-256 |
bdacf5edc453116a205ed02b5c74be9bac938b0006fdb327df82638573b04a8d
|
Provenance
The following attestation bundles were made for benzene_kafka-0.1.0b1-py3-none-any.whl:
Publisher:
release.yml on daniellepelley/benzene-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
benzene_kafka-0.1.0b1-py3-none-any.whl -
Subject digest:
977e9138ce13dc478e720644b6aae2ade3e6f8ab9b554fc2231eff1c5318b288 - Sigstore transparency entry: 2467214258
- Sigstore integration time:
-
Permalink:
daniellepelley/benzene-python@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/daniellepelley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@7f3c0d2abeeb3782a82a8e2621ee8b431bf02ca8 -
Trigger Event:
workflow_dispatch
-
Statement type: