Skip to content

Commit

Permalink
Implement synchronous queue to be used in test purposes
Browse files Browse the repository at this point in the history
  • Loading branch information
ifesdjeen committed Feb 8, 2016
1 parent 09e8c36 commit 5993f6a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/io/cyanite/test_helper.clj
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,29 @@
(deref [this]
0))

(defrecord SynchronousQueue [consumers]
component/Lifecycle
(start [this]
(let [q (assoc this :consumers (atom []))]
(assoc this :consumers (atom []) :ingestq q :writeq q)))
(stop [this]
(assoc this :consumers nil))
queue/QueueEngine
(shutdown! [this])
(add! [this e]
(doseq [f @consumers]
(f e)))
(consume! [this f]
(swap! consumers conj f)))

(def ^:dynamic *system*)

(defn make-test-system
[config]
(-> config
(update :clock #(map->TimeTravellingClock %))
(update :drift #(component/using (map->NoOpDrift %) [:clock]))
(update :queues queue/map->BlockingMemoryQueue)
(update :queues map->SynchronousQueue)
(update :index index/build-index)
(update :writer #(component/using (map->MemoryWriter %) [:index
:queues]))))
Expand Down

0 comments on commit 5993f6a

Please sign in to comment.