Created
February 9, 2017 16:52
-
-
Save jcf/aea2a9682ce6c65d57c905cccb25c885 to your computer and use it in GitHub Desktop.
Slurp the contents of your Onyx log into memory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn slurp-log | |
([peer-client-config] (slurp-log peer-client-config 2000)) | |
([peer-client-config wait] | |
(let [chan (clojure.core.async/chan) | |
sub (onyx.api/subscribe-to-log peer-client-config chan) | |
timeout (clojure.core.async/timeout wait) | |
xs (clojure.core.async/<!! | |
(clojure.core.async/go-loop [xs []] | |
(let [[val ch] (clojure.core.async/alts! [chan timeout])] | |
(if (= ch timeout) | |
xs | |
(recur (conj xs val))))))] | |
(-> sub :env onyx.api/shutdown-env) | |
xs))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment