Skip to content

Poll error callbacks #669

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

Closed
wants to merge 5 commits into from
Closed

Conversation

ignytis
Copy link

@ignytis ignytis commented Apr 10, 2024

Hello,

This PR adds a callback logic for errors occurred on poll method call in producer. The idea is to handle several kinds of errors immediately.

Here is a use case for this feature. If the application fails to connect or to authenticate to Kafka server then it exits with error code:
https://github.com/ignytis/send2kafka/blob/705f022beb50d8c8be77abbf6e15bd79707e9ebe/src/kafka_producer.rs#L32 <- setting the callback
https://github.com/ignytis/send2kafka/blob/705f022beb50d8c8be77abbf6e15bd79707e9ebe/src/kafka_producer.rs#L8-L13 <- callback itself
This way the connection issues might be handled before trying to send actual messages to the broker.

I'd appreciate any recommendations if there are any option to improve this code or implement this feature the other way.

@rhishikeshj
Copy link

rhishikeshj commented Jun 5, 2025

Perhaps a better design in keeping with the existing code would be to add an error callback to the ProducerContext trait similar to the delivery callback. And return some other useful error info. librdkafka also exposes functions for getting information about the errors, stuff like whether they are fatal and require termination etc. More is explained here

Since this is an old PR, maybe you have already moved on to something else, or your use-case is well covered by this implementation. :) In that case, feel free to ignore

Sorry this is already part of the master code

@ignytis
Copy link
Author

ignytis commented Jun 5, 2025

Looks like it's implemented in #771 indeed.

Anyway, thanks for pinging here, now I can close this old PR :)

@ignytis ignytis closed this Jun 5, 2025
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