Skip to content
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

Enable naming global-ktable local store #277

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/jackdaw/streams.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@
(defn global-ktable
"Creates a GlobalKTable that will consist of data from the specified
topic."
[streams-builder topic-config]
(p/global-ktable streams-builder topic-config))
([streams-builder topic-config]
(p/global-ktable streams-builder topic-config))
([streams-builder topic-config store-name]
(p/global-ktable streams-builder topic-config store-name)))


(defn source-topics
"Gets the names of source topics for the topology."
Expand Down
23 changes: 18 additions & 5 deletions src/jackdaw/streams/interop.clj
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@
^Consumed (topic->consumed topic-config)
^Materialized (topic->materialized (assoc topic-config
:topic-name store-name)))))))
(def ^:private global-ktable-memo
"Returns a global-ktable for the topic, creating a new one if needed."
(memoize
(fn [streams-builder {:keys [topic-name] :as topic-config}
store-name]
(clj-global-ktable
(.globalTable ^StreamsBuilder streams-builder
^String topic-name
^Consumed (topic->consumed topic-config)
^Materialized (topic->materialized (assoc topic-config
:topic-name store-name)))))))

(deftype CljStreamsBuilder [^StreamsBuilder streams-builder]
IStreamsBuilder
Expand Down Expand Up @@ -121,11 +132,13 @@
[_ topic-config store-name]
(ktable-memo streams-builder topic-config store-name))

(global-ktable [_ {:keys [topic-name] :as topic-config}]
(clj-global-ktable
(.globalTable ^StreamsBuilder streams-builder
^String topic-name
^Consumed (topic->consumed topic-config))))
(global-ktable
[_ {:keys [topic-name] :as topic-config}]
(global-ktable-memo streams-builder topic-config topic-name))

(global-ktable
[_ {:keys [topic-name] :as topic-config} store-name]
(global-ktable-memo streams-builder topic-config store-name))

(streams-builder*
[_]
Expand Down
3 changes: 2 additions & 1 deletion src/jackdaw/streams/protocols.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

(global-ktable
[topology-builder topic-config]
[topology-builder topic-config store-name]
"Creates a GlobalKTable that will consist of data from the specified
topic.")
topic.")

(source-topics
[topology-builder]
Expand Down