Current state: Draft
Discussion thread: here [Change the link from the KIP proposal email archive to your own email thread]
JIRA: KAFKA-20297
Please keep the discussion on the mailing list rather than commenting on the wiki (wiki discussions get unwieldy fast).
The Time interface and Timer class in org.apache.kafka.common.utils are currently exposed through public APIs but not officially designated as public. Following KIP-1247 (Make Bytes public), these should be made officially public.
// KafkaStreams constructors (test-only usage) public KafkaStreams(Topology topology, Properties props, Time time) // NetworkClientUtils methods public static boolean awaitReady(KafkaClient client, Node node, Time time, long timeoutMs) public static ClientResponse sendAndReceive(KafkaClient client, ClientRequest request, Time time) |
However, KafkaStreams exposes constructors accepting Time parameters that are only useful for testing, not production use. As noted in the KIP-1247 discussion, these test-only constructors should be deprecated before making Time the official public API.
Timer is returned by Time interface methods and users might interact with Timer's public methods. If Time becomes officially public, Timer must also be public as it is part of Time's contract.
org.apache.kafka.common.utils.Time (officially public)org.apache.kafka.common.utils.Timer (officially public)org.apache.kafka.streams.test.KafkaStreamsMock (test utility)KafkaStreams(Topology, Properties, Time) constructorKafkaStreams(Topology, Properties, KafkaClientSupplier, Time) constructorThese are only used for testing and pollute the public API.
Time and Timer officially public (4.4):Include Time and Timer in public API Javadocs with enhanced documentation.
KafkaStreams test constructors (4.4):Deprecate the following constructors (removal in 5.0):
KafkaStreams(Topology, Properties, Time)KafkaStreams(Topology, Properties, KafkaClientSupplier, Time)Create org.apache.kafka.streams.test.KafkaStreamsMock with static factory methods for creating KafkaStreams instances with custom Time implementations.
Example:
MockTime mockTime = new MockTime(); KafkaStreams streams = KafkaStreamsMock.create(topology, props, mockTime); |
Time and Timer become officially public. KafkaStreams Time constructors will be deprecated but functional.// Before KafkaStreams streams = new KafkaStreams(topology, props, mockTime); // After KafkaStreams streams = KafkaStreamsMock.create(topology, props, mockTime); |
No changes required for production code.
This KIP primarily involves API designation and deprecation rather than functional changes. Testing will focus on:
Time and Timer appear correctly in public API documentationKafkaStreams instances with custom Time implementationsNo new system tests required. Time and Timer functionality remains unchanged, only their API designation and test access patterns are updated.
Keep test constructors public: Continues to pollute the public API with test-only functionality.