A mock library for confluent kafka
Project description
Mockafka-py is a python library for mocking kafka in memory
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
Release history Release notifications | RSS feed
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.6.tar.gz
(10.2 kB
view details)
Built Distribution
File details
Details for the file mockafka_py-0.0.6.tar.gz
.
File metadata
- Download URL: mockafka_py-0.0.6.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7250f3b71b73aa00d0ff04afaab8960a9c38b5cc28ef25c2be1ecbc25758e5d4 |
|
MD5 | 67a091af6390727eded3f4c64a08b05f |
|
BLAKE2b-256 | 3427957624f991dbc978212b2c42aae20a4fbf717ad3c6e2361dd062d3448f52 |
File details
Details for the file mockafka_py-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: mockafka_py-0.0.6-py3-none-any.whl
- Upload date:
- Size: 12.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bfe0137de5cfe7525f5b4e8b99fbaaa4c4d97408a3ef25db0265cdf548253600 |
|
MD5 | 1d01e1343430ba2ffb0469a1fb0a75cc |
|
BLAKE2b-256 | 74291995a90128ac6215fa408f4299b3d1a0ed94cc2d6dc606c62080ebadbe86 |