omnixys-kafka
Omnixys shared async Kafka package — envelope producer, consumer with retry/DLQ/idempotency/circuit-breaker, decorator-driven handler dispatch, and header/topic utilities.
Installation
pip install omnixys-kafka
Features
- Envelope producer:
AIOKafkaEventProducerbuilds versionedKafkaEnvelopes and injects OpenTelemetry trace headers - Consumer: reliable
KafkaConsumerwith manual offset commit, partition pausing for delayed retries, per-topic circuit breakers and optional idempotency - Retry/DLQ: exponential backoff onto
<topic>.retry, dead-lettering onto<topic>.dlqaftermax_retries - Handler decorators:
@kafka_handler(topic),KafkaHandlerRegistry,KafkaEventDispatcherfor in-process dispatch - Headers:
create_kafka_headers()/KafkaHeaderCarrierbuilder andparse_headers()for the aiokafka wire format - Topics:
retry_topic_name,dlq_topic_name,original_topic_name,expand_topic_names— one source of truth for derived topic names - DI:
KafkaProvidercontainer integration (dishka) - Serialization: compact JSON with UUID/
datetimesupport
Usage
Handler registration (decorator + dispatcher)
from kafka import KafkaEventDispatcher, KafkaEnvelope, kafka_handler
@kafka_handler("event.created")
async def on_event_created(envelope: KafkaEnvelope, headers: dict[str, str]) -> None:
print(envelope.event_id, envelope.payload, headers.get("x-request-id"))
dispatcher = KafkaEventDispatcher()
await dispatcher.dispatch("event.created", envelope, {"x-request-id": "r1"})
# or from raw bytes:
await dispatcher.dispatch_raw("event.created", value, [("x-retry-count", b"0")])
Producing
from aiokafka import AIOKafkaProducer
from kafka import AIOKafkaEventProducer
producer = AIOKafkaEventProducer(
AIOKafkaProducer(bootstrap_servers="localhost:9092", enable_idempotence=True)
)
await producer.publish(event_name="event.created", payload={...}, topic="event.created", service="ticketing")
await producer.publish_raw("event.created.dlq", b"...", key="user-42")
Consuming with retry and DLQ
from kafka import KafkaConsumer, RetryConfig
consumer = KafkaConsumer(
consumer=raw_consumer, # aiokafka.AIOKafkaConsumer
bootstrap_servers="localhost:9092",
retry_config=RetryConfig(max_retries=5),
)
consumer.register_handler("event.created", on_event_created)
await consumer.start()
Failures are retried with exponential backoff into event.created.retry, and dead-lettered into event.created.dlq once max_retries is exhausted. Header metadata (x-original-topic, x-retry-count, x-retry-at) routes retries back to the right handler.
Headers and topics
from kafka import create_kafka_headers, expand_topic_names, retry_topic_name
headers = create_kafka_headers()
headers.set("x-meta-service", "user")
retry_topic_name("event.created") # "event.created.retry"
expand_topic_names(["event.created"]) # original + retry + dlq variants
Testing
The package ships behavior-level tests (pytest, no broker needed):
uv run pytest -q # 29 tests
uv run ruff check . # lint
uv run mypy src/ # strict typing
License
GPL-3.0-or-later
Metadata
Release files for omnixys-kafka 4.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| omnixys_kafka-4.0.0.tar.gz | 47.6 kB | Without provenance | Details for omnixys_kafka-4.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| omnixys_kafka-4.0.0-py3-none-any.whl | Python 3 | none | any | Details for omnixys_kafka-4.0.0-py3-none-any.whl |
Total release size: 60.8 kB
Release files / omnixys_kafka-4.0.0.tar.gz
| Download URL | omnixys_kafka-4.0.0.tar.gz |
|---|---|
| Size | 47.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
aa59fb6ac574d0d926a2b8189f65607da9ae4789c86f1e5ad03b00dd08701e2a
|
|
BLAKE2b-256 checksum How to use checksums |
96af616dfa2f923c39b64fbf80428c6e98f001e9125f5f2b99e0b4dbefcef401
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / omnixys_kafka-4.0.0-py3-none-any.whl
| Download URL | omnixys_kafka-4.0.0-py3-none-any.whl |
|---|---|
| Size | 13.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e293c85296504ea528b765ff613a8020d1a298a748b65e1d4689781113ef7db0
|
|
BLAKE2b-256 checksum How to use checksums |
c8eb06fb89267d4be077037f3bc49f705c107620eface082d62e899833090df9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.8 {"installer":{"name":"uv","version":"0.12.8","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for omnixys-kafka 4.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.