Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix implementation of repeated single-message fetching #110

Merged
merged 1 commit into from
Jul 6, 2024

Conversation

PeterJCLaw
Copy link
Collaborator

@PeterJCLaw PeterJCLaw commented Jul 6, 2024

Summary

This brings the mock implementations in line with the behaviour observed in the default configurations of confluent-kafka and aiokafka respectively, both of which return subsequent messages on subsequent calls.

Testing

Tested by running kafka locally and validating the behaviour of the relevant libraries manually. Commands & demo scripts below.

$ docker run --detach -p 9092:9092 --rm apache/kafka
$ docker run -it --network=host --rm apache/kafka /opt/kafka/bin/kafka-topics.sh --bootstrap-server localhost:9092 --create --topic testing-topic
$ docker run -it --network=host --rm apache/kafka /opt/kafka/bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic testing-topic
import uuid
import confluent_kafka

def main():
    consumer = confluent_kafka.Consumer({
        'bootstrap.servers': 'localhost:9092',
        'group.id': f'testing-group-{uuid.uuid4()}',
    })
    consumer.subscribe(['testing-topic'])
    print("Running")
    while True:
        msg = consumer.poll()
        print((msg.topic(), msg.key(), msg.value()))

main()
import asyncio
import aiokafka

async def main():
    consumer = aiokafka.AIOKafkaConsumer('testing-topic')
    await consumer.start()
    print("Running")
    while True:
        print(await consumer.getone())

asyncio.run(main())

@PeterJCLaw PeterJCLaw marked this pull request as ready for review July 6, 2024 15:09
This brings the mock implementations in line with the behaviour
observed in the default configurations of `confluent-kafka` and
`aiokafka` respectively, both of which return subsequent messages
on subsequent calls.
Copy link
Owner

@alm0ra alm0ra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the changes and everything looks great

@alm0ra alm0ra merged commit 359ba0a into alm0ra:main Jul 6, 2024
10 checks passed
@PeterJCLaw PeterJCLaw deleted the fix-repeated-fetch branch July 6, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants