Skip to main content

A simple Python SDK for Apache Kafka

Project description

py-kafka-sdk

A simple Python SDK for Apache Kafka, providing:

  • Asynchronous producer abstraction
  • Multi-threaded consumer utilities
  • Batch and single-message consumption

Requirements

Installation

Install dependencies:

pip install -r requirements.txt

Environment Variables

Configure using a .env file or environment variables:

KAFKA_BROKERS=localhost:9092
KAFKA_TOPICS=test-topic
KAFKA_GROUP_ID=test-group

Running Kafka Locally (Docker Compose)

See the included docker-compose.yml file.

Start Kafka:

docker-compose up -d

Usage

Producer Example

See examples/producer_example.py:

python examples/producer_example.py

Consumer Example

See examples/consumer_example.py:

python examples/consumer_example.py

Running Tests

To run all tests (Kafka must be running on localhost:9092):

pytest tests/test_producer.py
pytest tests/test_consumer.py

Note: Run the consumer test last, as it waits for a message sent by the producer test.

Notes

  • No brokers or topics are hardcoded; provide them via environment variables or parameters.
  • See the code for advanced usage (batch consumption, custom configs, etc).

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

py_kafka_sdk-0.1.1.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

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

py_kafka_sdk-0.1.1-py3-none-any.whl (1.7 kB view details)

Uploaded Python 3

File details

Details for the file py_kafka_sdk-0.1.1.tar.gz.

File metadata

  • Download URL: py_kafka_sdk-0.1.1.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for py_kafka_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 224b58ed94052cef5a2cfab8abcbcd1902e17e698db6ccd82d7a94fa140ce31c
MD5 e0e3848d30cea277e925389962d6d330
BLAKE2b-256 5f1c696188e4f1546447db4aa858cc5d480531db171d51d93b1dedf74b88ad97

See more details on using hashes here.

File details

Details for the file py_kafka_sdk-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: py_kafka_sdk-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 1.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for py_kafka_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 cba0444f7860615ee62d7bd26b30619ef7c65f7b6f9f9aa786f0b5751cd4351c
MD5 01bb95409dd8c658d448f38a34ef562e
BLAKE2b-256 ccb8fd07628d748e450b78fb95016bfc523ddb52269ec5e47a29e3561c2e6784

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