Skip to content

Commit

Permalink
Derive mock context local storage from that specified in job-config
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Chambers committed Mar 4, 2016
1 parent cfa5b6d commit 2e72d10
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions src/samza_config/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
(:require
[clojure.string :as str]
[samza-config.core :refer [*samza-system-name* *samza-stream-name*]]
[samza-config.job :refer [samza-config]]
[manifold.stream :as s]
[manifold.deferred :as d])
[samza-config.job :refer [samza-config]])
(:import
[io.confluent.kafka.schemaregistry.client LocalSchemaRegistryClient]
[org.apache.samza.config MapConfig]
Expand Down Expand Up @@ -36,21 +34,21 @@
(put [this k v]
(swap! store assoc k v))

#_(delete [this k]
(delete [this k]
(swap! store dissoc k))

#_(getAll [this ks]
(getAll [this ks]
(map #(get @store %) ks))

#_(putAll [this entries]
(putAll [this entries]
(doseq [e entries]
(swap! store assoc (.getKey e) (.getValue e))))

#_(deleteAll [this ks]
(deleteAll [this ks]
(doseq [k ks]
(.delete this k)))

#_(range [this from to]
(range [this from to]
(filter (fn [[k v]]
(and (<= k to)
(>= k from)))
Expand All @@ -62,7 +60,15 @@
(shutdown [this scope])))

(defn mock-task-context [job-config]
(let [stores {"email-results" (mock-kv-store)}]
(let [stores (->> (:stores job-config)
(map (fn [[store-name store-serdes]]
;; TODO:
;;
;; It wouldn't be hard to put objects through whatever serializer
;; is defined for the store.
[(name store-name) (mock-kv-store)]))
(mapcat identity)
(apply hash-map))]
(reify
TaskContext
(getStore [this store]
Expand Down

0 comments on commit 2e72d10

Please sign in to comment.