aiokafka-foundation-kit
Async Kafka foundation library with producer, consumer, metrics, and Dishka providers built on aiokafka.
Features
- 🚀 AsyncIO-first: Built on top of
aiokafkafor high-performance async operations - 📊 Observability: Built-in Prometheus metrics and OpenTelemetry support
- 🔧 Pydantic Settings: Type-safe configuration with Pydantic
- 💉 Dishka Integration: Dependency injection providers for easy integration
- 🔄 Retry Logic: Configurable retry policies with
tenacity - 🏥 Health Checks: Kafka cluster health monitoring
- 📝 Topic Management: Automatic topic creation and management
- 🎯 Type-Safe: Full type annotations with mypy strict mode
Installation
# Core functionality
pip install aiokafka-foundation-kit
# With all optional dependencies
pip install aiokafka-foundation-kit[all]
# Or specific features
pip install aiokafka-foundation-kit[models,orjson,dishka,dependency-injector,telemetry]
Quick Start
Producer Example
from aiokafka_foundation_kit import (
BaseKafkaProducerSettings,
AsyncKafkaPublisher,
create_async_kafka_producer,
)
# Configure
settings = BaseKafkaProducerSettings(
bootstrap_servers="localhost:9092",
)
# Create producer
producer = create_async_kafka_producer(settings)
await producer.start()
# Create publisher
publisher = AsyncKafkaPublisher(producer)
await publisher.start()
# Publish
await publisher.publish(
topic="events",
value={"event": "user_created", "user_id": "123"},
event_type="user_created",
)
Consumer Example
from aiokafka_foundation_kit import (
BaseKafkaConsumerSettings,
AsyncKafkaConsumerRunner,
create_async_kafka_consumer,
)
# Configure
settings = BaseKafkaConsumerSettings(
bootstrap_servers="localhost:9092",
group_id="my-group",
)
# Create consumer
consumer = create_async_kafka_consumer(settings, topics=["events"])
client = AsyncKafkaConsumerClient(consumer)
await client.start()
# Handle messages
async def handle(message):
print(f"Received: {message.value}")
runner = AsyncKafkaConsumerRunner(client, handle)
await runner.start()
Documentation
Full documentation at bedrock-python.github.io/aiokafka-foundation-kit.
Development
# Install dependencies
uv sync --group dev
# Run tests
make test
# Run linter
make lint
# Format code
make fmt
License
Apache 2.0 — see LICENSE for details.
Metadata
Release files for aiokafka-foundation-kit 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| aiokafka_foundation_kit-0.1.1.tar.gz | 21.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aiokafka_foundation_kit-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 58.9 kB
Release files / aiokafka_foundation_kit-0.1.1.tar.gz
| Download URL | aiokafka_foundation_kit-0.1.1.tar.gz |
|---|---|
| Size | 21.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ae723602bcab9fad079b7527d10bf3b58a21f90b8b40b0c63fa26ccc8e7df6b6
|
|
BLAKE2b-256 checksum How to use checksums |
af80785edc9f364c0eb30478fac60b44d59d36c2c7f65245e4a42563f80dba28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / aiokafka_foundation_kit-0.1.1-py3-none-any.whl
| Download URL | aiokafka_foundation_kit-0.1.1-py3-none-any.whl |
|---|---|
| Size | 37.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8e64555ff56bd913a4534d7ea4055c11cda6401cc0357826705fef9e73260921
|
|
BLAKE2b-256 checksum How to use checksums |
54444d3bac70bd883edbd1e37e5419e4f99005f04bfa85cf2013fd9854f12af2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|