Skip to main content

A mock library for confluent kafka

Project description

Alt text

Mockafka-py is a python library for mocking kafka in memory

GitHub Workflow Status (with event) GitHub Codecov GitHub release (with filter)

Mockafka

fake version of confluent-kafka-python

Features

  • compatible with confluent-kafka
  • Produce, Consume, AdminClient operations with ease.

TODO

Getting Start

Installing using pip

pip install mockafka-py

Usage

from mockafka import FakeProducer, FakeConsumer, FakeAdminClientImpl
from mockafka.admin_client import NewTopic
from random import randint

# create topic
admin = FakeAdminClientImpl()
admin.create_topics([
    NewTopic(topic='test', num_partitions=5)
])

# produce message
producer = FakeProducer()
for i in range(0, 10):
    producer.produce(
        topic='test',
        key=f'test_key{i}',
        value=f'test_value{i}',
        partition=randint(0, 4)
    )

# subscribe consumer
consumer = FakeConsumer()
consumer.subscribe(topics=['test'])

# consume messages

while True:
    message = consumer.poll()
    print(message)
    consumer.commit()

    if message is None:
        break

"""
out put
<mockafka.message.Message object at 0x7fe84b4c3310>
<mockafka.message.Message object at 0x7fe84b4c3370>
<mockafka.message.Message object at 0x7fe84b4c33a0>
<mockafka.message.Message object at 0x7fe84b4c33d0>
<mockafka.message.Message object at 0x7fe84b4c3430>
<mockafka.message.Message object at 0x7fe84b4c32e0>
<mockafka.message.Message object at 0x7fe84b4c31f0>
<mockafka.message.Message object at 0x7fe84b4c32b0>
<mockafka.message.Message object at 0x7fe84b4c3400>
<mockafka.message.Message object at 0x7fe84b4c3340>
None
"""

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

mockafka_py-0.0.9.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

mockafka_py-0.0.9-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file mockafka_py-0.0.9.tar.gz.

File metadata

  • Download URL: mockafka_py-0.0.9.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for mockafka_py-0.0.9.tar.gz
Algorithm Hash digest
SHA256 2f1fb1efcd307807e88a476b3af471318bb1bc35cb3a515c2700488037470167
MD5 acaecb3a343833b6870f024ac510cc40
BLAKE2b-256 da1f0f62e078de51a2150335e5e94386d97efc2bdb228f93d48499c30f5d76d2

See more details on using hashes here.

File details

Details for the file mockafka_py-0.0.9-py3-none-any.whl.

File metadata

  • Download URL: mockafka_py-0.0.9-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for mockafka_py-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 88e36f2c5315d7ccd5eec28f67dae057f7bbc1eb6117f0aedab609db9a44a127
MD5 9756fb9c408362518ad8103f9cea32f3
BLAKE2b-256 7c3af7f6e01b439cd852911b63bcb6fbdd27edac8d2b21250892a4cd2be77513

See more details on using hashes here.

Supported by

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