1
1
/**
2
- * Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
3
- */
2
+ * Copyright (C) 2018 Lightbend Inc. <https://www.lightbend.com>
3
+ */
4
4
5
5
package com .lightbend .kafka .scala .streams
6
6
7
7
import java .util .regex .Pattern
8
8
9
- import ImplicitConversions ._
10
- import org .apache .kafka .streams .kstream .{ GlobalKTable , Materialized }
9
+ import com .lightbend .kafka .scala .streams .ImplicitConversions ._
10
+ import org .apache .kafka .common .utils .Bytes
11
+ import org .apache .kafka .streams .kstream .{GlobalKTable , Materialized }
11
12
import org .apache .kafka .streams .processor .{ProcessorSupplier , StateStore }
12
- import org .apache .kafka .streams .state .{ StoreBuilder , KeyValueStore }
13
+ import org .apache .kafka .streams .state .{KeyValueStore , StoreBuilder }
13
14
import org .apache .kafka .streams .{Consumed , StreamsBuilder , Topology }
14
- import org .apache .kafka .common .utils .Bytes
15
15
16
16
import scala .collection .JavaConverters ._
17
17
18
18
/**
19
- * Wraps the Java class StreamsBuilder and delegates method calls to the underlying Java object.
20
- */
21
- class StreamsBuilderS {
19
+ * Wraps the Java class StreamsBuilder and delegates method calls to the underlying Java object.
20
+ */
21
+ class StreamsBuilderS ( inner : StreamsBuilder = new StreamsBuilder ) {
22
22
23
- val inner = new StreamsBuilder
23
+ def stream [K , V ](topic : String ): KStreamS [K , V ] =
24
+ inner.stream[K , V ](topic)
24
25
25
- def stream [K , V ](topic : String ) : KStreamS [K , V ] =
26
- inner.stream[K , V ](topic)
26
+ def stream [K , V ](topic : String , consumed : Consumed [ K , V ]) : KStreamS [K , V ] =
27
+ inner.stream[K , V ](topic, consumed )
27
28
28
- def stream [K , V ](topic : String , consumed : Consumed [K , V ]) : KStreamS [K , V ] =
29
- inner.stream[K , V ](topic, consumed)
30
-
31
- def stream [K , V ](topics : List [String ]): KStreamS [K , V ] =
32
- inner.stream[K , V ](topics.asJava)
29
+ def stream [K , V ](topics : List [String ]): KStreamS [K , V ] =
30
+ inner.stream[K , V ](topics.asJava)
33
31
34
32
def stream [K , V ](topics : List [String ], consumed : Consumed [K , V ]): KStreamS [K , V ] =
35
- inner.stream[K , V ](topics.asJava, consumed)
33
+ inner.stream[K , V ](topics.asJava, consumed)
36
34
37
- def stream [K , V ](topicPattern : Pattern ) : KStreamS [K , V ] =
35
+ def stream [K , V ](topicPattern : Pattern ): KStreamS [K , V ] =
38
36
inner.stream[K , V ](topicPattern)
39
37
40
- def stream [K , V ](topicPattern : Pattern , consumed : Consumed [K , V ]) : KStreamS [K , V ] =
38
+ def stream [K , V ](topicPattern : Pattern , consumed : Consumed [K , V ]): KStreamS [K , V ] =
41
39
inner.stream[K , V ](topicPattern, consumed)
42
40
43
- def table [K , V ](topic : String ) : KTableS [K , V ] = inner.table[K , V ](topic)
41
+ def table [K , V ](topic : String ): KTableS [K , V ] = inner.table[K , V ](topic)
44
42
45
- def table [K , V ](topic : String , consumed : Consumed [K , V ]) : KTableS [K , V ] =
43
+ def table [K , V ](topic : String , consumed : Consumed [K , V ]): KTableS [K , V ] =
46
44
inner.table[K , V ](topic, consumed)
47
45
48
46
def table [K , V ](topic : String , consumed : Consumed [K , V ],
49
- materialized : Materialized [K , V , KeyValueStore [Bytes , Array [Byte ]]]): KTableS [K , V ] =
50
- inner.table[K , V ](topic, consumed, materialized)
47
+ materialized : Materialized [K , V , KeyValueStore [Bytes , Array [Byte ]]]): KTableS [K , V ] =
48
+ inner.table[K , V ](topic, consumed, materialized)
51
49
52
- def table [K , V ](topic : String ,
53
- materialized : Materialized [K , V , KeyValueStore [Bytes , Array [Byte ]]]): KTableS [K , V ] =
50
+ def table [K , V ](topic : String ,
51
+ materialized : Materialized [K , V , KeyValueStore [Bytes , Array [Byte ]]]): KTableS [K , V ] =
54
52
inner.table[K , V ](topic, materialized)
55
53
56
54
def globalTable [K , V ](topic : String ): GlobalKTable [K , V ] =
57
55
inner.globalTable(topic)
58
56
59
- def addStateStore (builder : StoreBuilder [_ <: StateStore ]): StreamsBuilder = inner.addStateStore(builder)
57
+ def globalTable [K , V ](topic : String , consumed : Consumed [K , V ]): GlobalKTable [K , V ] =
58
+ inner.globalTable(topic, consumed)
60
59
61
- def addGlobalStore (storeBuilder : StoreBuilder [_ <: StateStore ], topic : String , sourceName : String , consumed : Consumed [_, _], processorName : String , stateUpdateSupplier : ProcessorSupplier [_, _]): StreamsBuilder =
62
- inner.addGlobalStore(storeBuilder,topic,sourceName,consumed,processorName,stateUpdateSupplier)
60
+ def globalTable [K , V ](topic : String , consumed : Consumed [K , V ],
61
+ materialized : Materialized [K , V , KeyValueStore [Bytes , Array [Byte ]]]): GlobalKTable [K , V ] =
62
+ inner.globalTable(topic, consumed, materialized)
63
+
64
+ def globalTable [K , V ](topic : String ,
65
+ materialized : Materialized [K , V , KeyValueStore [Bytes , Array [Byte ]]]): GlobalKTable [K , V ] =
66
+ inner.globalTable(topic, materialized)
63
67
64
- def build () : Topology = inner.build()
65
- }
68
+ def addStateStore (builder : StoreBuilder [_ <: StateStore ]): StreamsBuilder = inner.addStateStore(builder)
66
69
70
+ def addGlobalStore (storeBuilder : StoreBuilder [_ <: StateStore ], topic : String , sourceName : String , consumed : Consumed [_, _], processorName : String , stateUpdateSupplier : ProcessorSupplier [_, _]): StreamsBuilder =
71
+ inner.addGlobalStore(storeBuilder, topic, sourceName, consumed, processorName, stateUpdateSupplier)
67
72
73
+ def build (): Topology = inner.build()
74
+ }
0 commit comments