You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Tombert (via GitHub)" <gi...@apache.org> on 2025/04/03 18:12:36 UTC
[PR] Minor: Add functionalinterface to the producer callback [kafka]
Tombert opened a new pull request, #19366:
URL: https://github.com/apache/kafka/pull/19366
The Callback interface is a perfect example of a place that can use the functionalinterface in Java. Strictly for Java, this isn't "required" since Java will automatically coerce, but for Clojure (and other JVM languages I belive) to interop with Java lambdas it needs the FunctionalInterface annotation.
Since FunctionalInterface doesn't add any overhead and provides compiler-enforced documentation, I don't see any reason *not* to have this. This has already been added into Kafka Streams here: https://github.com/apache/kafka/pull/19234#pullrequestreview-2740742487
I am happy to add it to any other spots in that might be useful too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Add functionalinterface to the producer callback [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19366:
URL: https://github.com/apache/kafka/pull/19366#discussion_r2027583667
##########
clients/src/main/java/org/apache/kafka/clients/consumer/AcknowledgementCommitCallback.java:
##########
@@ -34,6 +34,7 @@
* The callback may be executed in any thread calling {@link ShareConsumer#poll(java.time.Duration)}.
*/
@InterfaceStability.Evolving
+@FunctionalInterface
Review Comment:
> but I just think that the word "callback" itself implies some form of "response handler" function. I will stay within Kafka's nomenclature, I just thought that that was more or less the terminology.
yes, I agree that. My point was the interface is in evolving, so it is not urgent to add the annotation for now. However, that is personal taste rather than strong reason. We can add the annotation after it is in stable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Add functionalinterface to the producer callback [kafka]
Posted by "Tombert (via GitHub)" <gi...@apache.org>.
Tombert commented on code in PR #19366:
URL: https://github.com/apache/kafka/pull/19366#discussion_r2027542000
##########
clients/src/main/java/org/apache/kafka/clients/consumer/AcknowledgementCommitCallback.java:
##########
@@ -34,6 +34,7 @@
* The callback may be executed in any thread calling {@link ShareConsumer#poll(java.time.Duration)}.
*/
@InterfaceStability.Evolving
+@FunctionalInterface
Review Comment:
Forgive me a bit here, I'm still kind of learning the Kafka codebase, but I just think that the word "callback" itself implies some form of "response handler" function. I will stay within Kafka's nomenclature, I just thought that that was more or less the terminology.
`ConsumerRebalanceListener` can't be made into a `@FunctionalInterface` in its current state because it has more than one method.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Add functionalinterface to the producer callback [kafka]
Posted by "Tombert (via GitHub)" <gi...@apache.org>.
Tombert commented on code in PR #19366:
URL: https://github.com/apache/kafka/pull/19366#discussion_r2027527786
##########
clients/src/main/java/org/apache/kafka/clients/consumer/AcknowledgementCommitCallback.java:
##########
@@ -34,6 +34,7 @@
* The callback may be executed in any thread calling {@link ShareConsumer#poll(java.time.Duration)}.
*/
@InterfaceStability.Evolving
+@FunctionalInterface
Review Comment:
Is there any reason not to have it even now? It's still a callback meaning I don't think there's any particular reason not to have the annotation, but I will happily admit I'm wrong if you think it's bad. I can remove it if you think it's bad to put it in.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Add functionalinterface to the producer callback [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19366:
URL: https://github.com/apache/kafka/pull/19366#discussion_r2027536151
##########
clients/src/main/java/org/apache/kafka/clients/consumer/AcknowledgementCommitCallback.java:
##########
@@ -34,6 +34,7 @@
* The callback may be executed in any thread calling {@link ShareConsumer#poll(java.time.Duration)}.
*/
@InterfaceStability.Evolving
+@FunctionalInterface
Review Comment:
> It's still a callback meaning I don't think there's any particular reason not to have the annotation
Excuse me, do you mean "callback" should be functional interface? If so, it is not the rule in code base. For example, `ConsumerRebalanceListener` is a kind of callback, but it does not have `@FunctionalInterface`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Add functionalinterface to the producer callback [kafka]
Posted by "Tombert (via GitHub)" <gi...@apache.org>.
Tombert commented on code in PR #19366:
URL: https://github.com/apache/kafka/pull/19366#discussion_r2027530949
##########
clients/src/main/java/org/apache/kafka/clients/consumer/AcknowledgementCommitCallback.java:
##########
@@ -34,6 +34,7 @@
* The callback may be executed in any thread calling {@link ShareConsumer#poll(java.time.Duration)}.
*/
@InterfaceStability.Evolving
+@FunctionalInterface
Review Comment:
Removed it for now, will revisit once it's stable .
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Add functionalinterface to the producer callback [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19366:
URL: https://github.com/apache/kafka/pull/19366#discussion_r2027523376
##########
clients/src/main/java/org/apache/kafka/clients/consumer/AcknowledgementCommitCallback.java:
##########
@@ -34,6 +34,7 @@
* The callback may be executed in any thread calling {@link ShareConsumer#poll(java.time.Duration)}.
*/
@InterfaceStability.Evolving
+@FunctionalInterface
Review Comment:
share consumer is not production-ready, so we should add the annotation later.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Minor: Add functionalinterface to the producer callback [kafka]
Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #19366:
URL: https://github.com/apache/kafka/pull/19366
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org