Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
Just use a fn.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Drogalis committed Dec 25, 2014
1 parent 74fc197 commit 6757d3f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
19 changes: 7 additions & 12 deletions src/onyx/api.clj
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,12 @@
(doall
(map
(fn [_]
(let [stop-ch (chan (clojure.core.async/sliding-buffer 1))
v-peer (system/onyx-peer config)]
{:runner (future
(let [live (component/start v-peer)]
(let [ack-ch (<!! stop-ch)]
(component/stop live)
(>!! ack-ch true)
(close! ack-ch))))
:shutdown-fn (fn []
(let [ack-ch (chan)]
(>!! stop-ch ack-ch)
(<!! ack-ch)))}))
(let [v-peer (system/onyx-peer config)]
(component/start v-peer)))
(range n))))

(defn shutdown
"Shutdowns the given resource - presumably either a peer or dev env."
[resource]
(component/stop resource))

4 changes: 2 additions & 2 deletions test/onyx/peer/single_peer_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@
(def results (hq-util/consume-queue! hq-config out-queue echo))

(doseq [v-peer v-peers]
((:shutdown-fn v-peer)))
(onyx.api/shutdown v-peer))

(let [expected (set (map (fn [x] {:n (inc x)}) (range n-messages)))]
(fact (set (butlast results)) => expected)
(fact (last results) => :done))

(component/stop env)
(onyx.api/shutdown env)

0 comments on commit 6757d3f

Please sign in to comment.