alm0ra / mockafka-py Goto Github PK
View Code? Open in Web Editor NEWMockafka-py is a Python library designed for in-memory mocking of Kafka.[aiokafka - confluence-kafka-python]
Home Page: https://mockafka-py.readthedocs.io
License: MIT License
Mockafka-py is a Python library designed for in-memory mocking of Kafka.[aiokafka - confluence-kafka-python]
Home Page: https://mockafka-py.readthedocs.io
License: MIT License
update readme for aiokafka support with examples
AIOkafka user here trying to make some tests ๐ก๏ธ
Describe the bug
aiokafka's version of send_and_wait
has 2 positional arguments (see https://aiokafka.readthedocs.io/en/stable/api.html#aiokafka.AIOKafkaProducer.send_and_wait). However, in FakeAIOKafkaProducer
these arguments aren't there and the *args and **kwargs are not properly passed from send_and_wait
to _produce
and you get an exception when using this function:
TypeError: FakeAIOKafkaProducer._produce() missing 1 required positional argument: 'topic'
To Reproduce
Steps to reproduce the behavior:
producer = FakeAIOKafkaProducer()
producer.send_and_wait("topic_name", "sdfjhasdfhjsa", key="datakey")
๐ฅ
Expected behavior
It should not throw an exception
Screenshots
/usr/local/lib/python3.12/site-packages/sentry_sdk/tracing_utils_py3.py:64: in func_with_tracing
return func(*args, **kwargs)
src/kafka.py:90: in process
asyncio.run(self.send_updated_records(plant_data.plant_key, updated_data))
/usr/local/lib/python3.12/asyncio/runners.py:194: in run
return runner.run(main)
/usr/local/lib/python3.12/asyncio/runners.py:118: in run
return self._loop.run_until_complete(task)
/usr/local/lib/python3.12/asyncio/base_events.py:685: in run_until_complete
return future.result()
src/kafka.py:106: in send_updated_records
await self.producer.send_and_wait(ct, serialized_record, key=plant_key)
/usr/local/lib/python3.12/site-packages/mockafka/aiokafka/aiokafka_producer.py:40: in send_and_wait
await self.send()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <mockafka.aiokafka.aiokafka_producer.FakeAIOKafkaProducer object at 0x7f5302d6dd30>, args = ()
kwargs = {}
async def send(self, *args, **kwargs):
> await self._produce(**kwargs)
E TypeError: FakeAIOKafkaProducer._produce() missing 1 required positional argument: 'topic'
Desktop (please complete the following information):
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.