exception doesn't work, try another technique
This commit is contained in:
parent
9a72e63932
commit
4f429f5463
2 changed files with 11 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
(defproject bigbrother "0.1.2"
|
||||
(defproject bigbrother "0.1.3-SNAPSHOT"
|
||||
:description "Periodically send metrics"
|
||||
:url "http://github.com/yogsototh/bigbrother"
|
||||
:license {:name "MIT"
|
||||
|
|
|
@ -109,14 +109,20 @@ end
|
|||
:state level
|
||||
:metric v}))))
|
||||
|
||||
(defmacro with-timeout [millis & body]
|
||||
`(let [future# (future ~@body)]
|
||||
(try
|
||||
(.get future# ~millis java.util.concurrent.TimeUnit/MILLISECONDS)
|
||||
(catch java.util.concurrent.TimeoutException x#
|
||||
(do
|
||||
(future-cancel future#)
|
||||
nil)))))
|
||||
|
||||
(defn send-to-riemann [m]
|
||||
(let [result-map (into @default-map m)
|
||||
events (remove nil? (map to-riemann-event result-map))]
|
||||
(when @riemann-conn
|
||||
(try
|
||||
(r/send-events @riemann-conn events)
|
||||
(catch Exception e
|
||||
(log/error e))))))
|
||||
(with-timeout 1000 (r/send-events @riemann-conn events)))))
|
||||
|
||||
|
||||
(defn reset-accumulators! []
|
||||
|
|
Loading…
Reference in a new issue