Current state: Under Discussion
Discussion thread: TDB
JIRA: N/A
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
Note this KIP is the original work of Ray McDermott - Due to lack of self-service signup for wiki ID and editing permissions, we're adding Ray's text to this KIP.
Jackdaw is a Clojure library over the Kafka Streams DSL. In its current state, Jackdaw uses wrappers around the DSL interfaces to enable function passing in Clojure as one would enjoy if using Java.
Such wrappers are verbose and add to complexity to the library. They would not be required if Clojure has first class interop for SAM interfaces.
The new Clojure version 1.12 has many updates to Java interop including SAM interfaces. Unfortunately, it does not quite deliver what we need with respect to thinning down Kafka Streams interop.
We were specifically hoping that passing (fn [] ...) to SAM interfaces would just work and thus we would no longer need to wrap the interface. This feature may eventually be added to the language but it currently only works for interfaces that have been explicitly annotated with @FunctionalInterface. See this JIRA ticket for details.
Java does not require the @FunctionalInterface annotation although it clarifies the intended interface purpose.
The Kafka Streams DSL does not have those annotations and this KIP proposes to add them.
Public Interfaces
No new interfaces or changes to the behavior of existing interfaces will be introduced in this KIP.
These annotations on the interfaces are new but do not affect client calls. Details of adding the annotation are in the next section.
Add @FunctionalInterface to the Kafka Streams DSL and the Processor API (PAPI).
The interface must conform to these rules:
default methodsObjectThe details of each included / excluded interface is as follows:
We will add @FunctionalInterface to these interfaces:
Aggregatorapply is the only method in the interface (SAM)ForeachActionapply is the only method in the interface (SAM)GlobalKTablequeryableStoreName is the only method in the interface (SAM)Initializerapply is the only method in the interface (SAM)KeyValueMapperapply is the only method in the interface (SAM)Mergerapply is the only method in the interface (SAM)NamedOperationwithName is the only method in the interface (SAM)Predicatetest is the only method in the interface (SAM)Reducerapply is the only method in the interface (SAM)TransformerSupplierget is the only method in the interface (SAM)ValueJoinerapply is the only method in the interface (SAM)ValueJoinerWithKeyapply is the only method in the interface (SAM)ValueMapperapply is the only method in the interface (SAM)ValueMapperWithKeyapply is the only method in the interface (SAM)ValueTransformerSupplierget is the only method in the interface (SAM)ValueTransformerWithKeySupplierget is the only method in the interface (SAM)We will not add it to these interfaces:
BranchedKStreamdefault methods so does not qualify.CogroupedKStreamdefault methods so does not qualify.EmitStrategydefault methods so does not qualify.KGroupedStreamdefault methods so does not qualify.KGroupedTabledefault methods so does not qualify.KStreamdefault methods so does not qualify.KTabledefault methods so does not qualify.SessionWindowedCogroupedKStreamaggregate is overloaded so does not qualify.SessionWindowedKStreamdefault methods so does not qualify.Suppresseddefault methods so does not qualify.TimeWindowedCogroupedKStreamaggregate is overloaded so does not qualify.TimeWindowedKStreamdefault methods so does not qualify.Transformerdefault methods so does not qualify.ValueTransformerdefault methods so does not qualify.ValueTransformerWithKeydefault methods so does not qualify.The PAPI already has two interfaces that have @FunctionalInterface which will be unaffected:
FixedKeyProcessorSupplierProcessorSupplier.We will add @FunctionalInterface to these interfaces:
FixedKeyProcessorprocess is the only non-default methodProcessorprocess is the only non-default methodWe will not add it to these interfaces:
FixedKeyProcessorContextforward is overloaded so does not qualify.ProcessingContextdefault methods so does not qualify.ProcessorContextforward is overloaded so does not qualify.RecordMetadatadefault methods so does not qualify.None required
Running the existing tests will be sufficient.
Leave off the @FunctionalInterface annotation: limits the benefits to non-Java, JVM languages.