-
Notifications
You must be signed in to change notification settings - Fork 6
Description
Hi, in our Kafka use cases where we return batches of messages over a REST API, we need to be able to fetch messages from all partitions for a specific topic only once, without having an infinite stream of messages. Seemingly, this library only provides ways to either create an infinite stream of messages with consumer.consume
or fetch topic messages of a single node with consumer.fetch
. Neither approach satisfies our requirement completely, and to implement a solution, we would have to duplicate a lot of library code.
I would like to request a feature that allows us to fetch all leaders of all topics very similarly to what is done in _read
of theMessageStream
class. I am willing to create a PR myself, but I would need some guidance on how to best implement it.
I was looking into the code and found two possible ways:
- Extend
consumer.consume
with an optionsingleFetch
or similar. Pass this option to the constructedMessageStream
. Inside_read
after fetching all the partition leaders, end the stream (bypush
ingnull
I guess?) if said option is set. - Create a new function,
consumer.fetchAll,
which is quite similar toconsumer.fetch
but includes checking and looping over all the partition leaders like in_read
.
Let me know what you think.