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

fetchOffsets should allow fetching offsets for all topics consumed by a consumerGroup #989

Closed
nirga opened this issue Dec 28, 2020 · 2 comments · Fixed by #992
Closed

fetchOffsets should allow fetching offsets for all topics consumed by a consumerGroup #989

nirga opened this issue Dec 28, 2020 · 2 comments · Fixed by #992

Comments

@nirga
Copy link
Contributor

nirga commented Dec 28, 2020

Is your feature request related to a problem? Please describe.
I'm writing a Kafka plugin to Backstage and want to use kafkajs. One of the features I'm developing is the ability to view all topics (+offsets) consumed by a consumer group so I need a way to fetch that from the Kafka cluster.

Describe the solution you'd like
Currently the only API I see that I can use for that is admin.fetchOffsets. However, it requires me to set the topic I want to fetch offset from even though the internal method doesn't seem to require it. I think we can remove the assertion that topic is not null on calls to admin.fetchOffsets with resolveOffsets===false.

Additional context
Backstage Issue #3791

@Nevon
Copy link
Collaborator

Nevon commented Dec 28, 2020

I'm writing a Kafka plugin to Backstage and want to use kafkajs.

Heh, is Tulio promoting KafkaJS at Spotify now? :D

Did you give it a try to make a request without explicitly listing topics? I can't see any reference to it in the Kafka protocol documentation, but reading the Java client it does look like if you don't provide any topic partitions in the OffsetsFetch request, it returns offsets for all known topics that the consumer group has committed offsets for.

I think it was a mistake to have the method accept a single topic, rather than an array of topics. We could do a polymorphic thing where we accept both types to avoid having to make a breaking change, but I'm pretty sure our implementation currently makes a lot of assumptions that we will have to revisit.

Would you be willing and able to start working on a PR for this?

@nirga
Copy link
Contributor Author

nirga commented Dec 28, 2020

Heh, is Tulio promoting KafkaJS at Spotify now? :D

Actually we use it internally at Fiverr and I like the simplicity of it so thought to adopt it for the plugin as well.
(EDIT: just realized Tulio is working at Spotify 🤓)

Did you give it a try to make a request without explicitly listing topics? I can't see any reference to it in the Kafka protocol documentation, but reading the Java client it does look like if you don't provide any topic partitions in the OffsetsFetch request, it returns offsets for all known topics that the consumer group has committed offsets for.

I haven't, but I think you're right - Kafka Java API provides an ability to do that:
https://kafka.apache.org/26/javadoc/org/apache/kafka/clients/admin/Admin.html#listConsumerGroupOffsets-java.lang.String-

Would you be willing and able to start working on a PR for this?

Definitely!

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 a pull request may close this issue.

2 participants