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

A lot of idling in KafkaConsumer.batchConsumerPoll #151

Closed
blindspotbounty opened this issue Nov 29, 2023 · 1 comment
Closed

A lot of idling in KafkaConsumer.batchConsumerPoll #151

blindspotbounty opened this issue Nov 29, 2023 · 1 comment

Comments

@blindspotbounty
Copy link
Collaborator

After #139 we noticed that there are a lot of idling in KafkaConsumer.batchConsumerPoll

Seems that now for-loop does not exit when there is no more messages:

    private func batchConsumerPoll(
        client: RDKafkaClient,
        maxMessages: Int = 100
    ) -> [Result<KafkaConsumerMessage, Error>] {
        var messageResults = [Result<KafkaConsumerMessage, Error>]()
        messageResults.reserveCapacity(maxMessages)

        for _ in 0..<maxMessages {
            var result: Result<KafkaConsumerMessage, Error>?
            do {
                if let message = try client.consumerPoll() {
                    result = .success(message)
                }
            } catch {
                result = .failure(error)
            }

            if let result {
                messageResults.append(result)
            }                                          ///   <-------- seems we should else { return messageResults }
        }

        return messageResults
    }

Not sure if it is intended. Could you advise, please?

@FranzBusch
Copy link
Contributor

Yes we should be doing that. Do you mind opening a PR?

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

No branches or pull requests

2 participants