Skip to content

Feature Request: Fetch all partitions of a topic once #71

@lp247

Description

@lp247

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:

  1. Extend consumer.consume with an option singleFetch or similar. Pass this option to the constructed MessageStream. Inside _read after fetching all the partition leaders, end the stream (by pushing null I guess?) if said option is set.
  2. Create a new function, consumer.fetchAll, which is quite similar to consumer.fetch but includes checking and looping over all the partition leaders like in _read.

Let me know what you think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions