Skip to content

Instantly share code, notes, and snippets.

@jcf
Created February 9, 2017 16:52
Show Gist options
  • Select an option

  • Save jcf/aea2a9682ce6c65d57c905cccb25c885 to your computer and use it in GitHub Desktop.

Select an option

Save jcf/aea2a9682ce6c65d57c905cccb25c885 to your computer and use it in GitHub Desktop.

Revisions

  1. James Conroy-Finn created this gist Feb 9, 2017.
    14 changes: 14 additions & 0 deletions onyx.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    (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)))