Skip to content

Instantly share code, notes, and snippets.

@lbradstreet
Created February 7, 2015 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lbradstreet/062ef5eb2fc641c8f9a2 to your computer and use it in GitHub Desktop.
Save lbradstreet/062ef5eb2fc641c8f9a2 to your computer and use it in GitHub Desktop.
(defn with-env-peers [env-config peer-config n-peers f]
(let [env (onyx.api/start-env env-config)
v-peers (onyx.api/start-peers! n-peers peer-config)]
(try
(f)
(finally
(doseq [v-peer v-peers]
(onyx.api/shutdown-peer v-peer))
(onyx.api/shutdown-env env)))))
(with-env-peers
env-config peer-config 3
(fn []
(onyx.api/submit-job
peer-config
{:catalog catalog :workflow workflow
:task-scheduler :onyx.task-scheduler/round-robin})
(let [results (doall (repeatedly n-messages (fn [] (<!! out-chan))))
expected (set (map (fn [x] {:n (inc x)}) (range n-messages)))]
(fact (set results) => expected)
; (fact (last results) => :done)
)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment