Skip to main content

Local Python SDK for kafka-light

Project description

kafka-light-python

kafka-light-python is a small Python SDK for producing and consuming events through the kafka-light gRPC transport.

Requirements

  • Python 3.13+
  • A reachable kafka-light server endpoint

Installation

pip install kafka-light-python

Quick Start

import asyncio

from kafka_light import KafkaLightConfig, KafkaLightConsumer, KafkaLightProducer, TopicPartition


async def main() -> None:
    config = KafkaLightConfig(brokers=["127.0.0.1:7171"])

    producer = KafkaLightProducer(config)
    await producer.start()
    await producer.send_and_wait("events", value={"message": "hello"})
    await producer.stop()

    consumer = KafkaLightConsumer(config, group_id="example-group", topics=["events"])
    await consumer.start()

    message = await consumer.__anext__()
    print(message.value)

    await consumer.commit({TopicPartition("events"): message.offset + 1})
    await consumer.stop()


asyncio.run(main())

Public API

  • KafkaLightConfig: broker endpoint configuration
  • KafkaLightProducer: async producer adapter
  • KafkaLightConsumer: async consumer adapter
  • PublishAck, ReceivedMessage, TopicPartition: shared transport models

Notes

  • The current client uses only the first configured broker endpoint.
  • Consumer support is currently limited to partition 0.
  • auto_offset_reset currently supports committed offsets or "earliest".

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kafka_light_python-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kafka_light_python-0.1.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

File details

Details for the file kafka_light_python-0.1.0.tar.gz.

File metadata

  • Download URL: kafka_light_python-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for kafka_light_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 02f2b615c3c8f911c6a9f045a704dfbbb58b97489d9c1b85373bf82ad9b42225
MD5 4d3f2aad619d675d051294e8ae245c0f
BLAKE2b-256 acf3f40289a7f3c05e45d58ac184077bde3667b5743ec4e163f0b6e9c0be1a8a

See more details on using hashes here.

File details

Details for the file kafka_light_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for kafka_light_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13b64d06039ec7281f306642a7f3142e93b282f0498bd95ba771536c3cb2a284
MD5 8360846d9d9a88a202e424ae520251e9
BLAKE2b-256 56731476541dc86838c8a4aa8637977a5e97b6076293a40d2fa0f2b0519690df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page