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

[#262] Fix inability to materialize without supplying a topic name #335

Open
wants to merge 1 commit 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

### Unreleased
- Fix inability to materialize without supplying a topic name

### [0.9.6] - [2022-08-01]

Expand Down
8 changes: 5 additions & 3 deletions src/jackdaw/streams/interop.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@
(Grouped/with key-serde value-serde))

(defn topic->materialized [{:keys [topic-name key-serde value-serde]}]
(cond-> (Materialized/as ^String topic-name)
key-serde (.withKeySerde key-serde)
value-serde (.withValueSerde value-serde)))
(if topic-name
(cond-> (Materialized/as ^String topic-name)
key-serde (.withKeySerde key-serde)
value-serde (.withValueSerde value-serde))
(Materialized/with key-serde value-serde)))

(defn suppress-config->suppressed
[{:keys [max-records max-bytes until-time-limit-ms]}]
Expand Down
15 changes: 15 additions & 0 deletions test/jackdaw/streams/interop_test.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
(ns jackdaw.streams.interop-test
(:require
[clojure.test :refer :all]
[jackdaw.streams.interop :as interop])
(:import
(org.apache.kafka.common.serialization
Serdes)))

(deftest topic->materialized-test
(testing "materialized with serde only doesn't smoke"
(is (interop/topic->materialized {:key-serde (Serdes/String)
:value-serde (Serdes/String)})))
(testing "materialized with topic name and serde doesn't smoke"
(is (interop/topic->materialized {:key-serde (Serdes/String)
:value-serde (Serdes/String)}))))