Skip to content

Instantly share code, notes, and snippets.

@lbradstreet
Last active October 4, 2016 17:04
Show Gist options
  • Save lbradstreet/b9366f228959b53fee62d1cb517c57bc to your computer and use it in GitHub Desktop.
Save lbradstreet/b9366f228959b53fee62d1cb517c57bc to your computer and use it in GitHub Desktop.
(ns onyx.metrics.riemann-playground)
(require '[riemann.client :as r])
(def c (r/tcp-client {:host "192.168.99.100" :port 35002}))
(defn intensive-computation []
(let [prom (r/send-events c (repeat 100000 {:status "ok"}))]
(println "Obtained promise")
(println (deref prom 5000 ::timeout5000))))
(def f (future
(try
(while (not (Thread/interrupted))
(println (Thread/interrupted))
(println "ready to go")
(println (intensive-computation)))
(catch Exception e
(println e)
(.interrupt (Thread/currentThread))
(throw (RuntimeException. e)))
(finally (println "finally")))))
(Thread/sleep 10000)
(future-cancel f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment