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.7.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

mockafka_py-0.0.7-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mockafka_py-0.0.7.tar.gz
  • Upload date:
  • Size: 7.6 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.7.tar.gz
Algorithm Hash digest
SHA256 625675d1ce13b544f9850bd19c3d9048b5a6169ed113a479d7e36557c8507ba9
MD5 f6fb30687a988b5e68d99a0431e630ca
BLAKE2b-256 5e2224d79aeac9f8ae11b1968d8536fb116ac04d69037e5f1b7321cc2114fcbe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mockafka_py-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 10.8 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 b4e18c1aea6ff3e558ae17ea815c7bf17984e06ae114a21aff8bd9676a848c93
MD5 d28665f3bd039433c56da280438a89c5
BLAKE2b-256 d65bd999c67f3882fbd5e814436f7ea872c11d5fef9152e28f11de040a8da001

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