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.8.tar.gz
(7.8 kB
view details)
Built Distribution
File details
Details for the file mockafka_py-0.0.8.tar.gz
.
File metadata
- Download URL: mockafka_py-0.0.8.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e90490f7bac5341648fee74728a6da0636d7b96d31bf39f31b033d8f9b6f8269 |
|
MD5 | 2830d71d3dd2c0a63e3bdf8c17165507 |
|
BLAKE2b-256 | 9982fd3a100abb824c276b179bad66c2672b6e6850cbb7e0d5c93b51f35bab9a |
File details
Details for the file mockafka_py-0.0.8-py3-none-any.whl
.
File metadata
- Download URL: mockafka_py-0.0.8-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d41e5730f0536047623ce91675fc0bb15669e66bcdbc2fd84e9207cfb81a8a5a |
|
MD5 | 9830bd6ea673741c96d35fff87918dad |
|
BLAKE2b-256 | 1fc0d2e3e6620fb2108032c9059b0df18e29c162857d4f54c0a46a7b28d3b0b9 |