Lighter Clojure replacement for Netflix hystrix latency and fault tolerance library
Basically: it runs tasks.
exec
functionqueue
functionqueue duration
is the overhead time between submission
and execution of the task.call duration
is the time took to purely execute the
taskerror-fn
) lets specify a side-effect to execute in case of
task failurefallback-fn
) is used to provide a default
value in case of task failureA commander is an object that implements the Commander
protocol. The above features are provided whatever the
implementation of the Commmander.
A commander implements the task scheduling and the metrics.
There are two commanders provided :
pumila.commander.simple
is a no dependency commander
that runs tasks out of a managed threadpool.pumila.commander.reference
is a commander based on
dirigiste (a finely managed threadpool implementation),
and metrics-clojure.You can implement your own commander, for example based on a ready made ExecutorService and micro-meter.
(defn get-my-uri
[uri]
(:body (http/get uri)))
;; this is a very basic commander, not suitable for production
;; you may want to use the one provided in pumila.commander.reference
(def commander (pmc/new-commander))
(let [;; async
f (pm/queue commander {:timeout 1000 :error-fn println :fallback-fn (constantly "I feel lucky!")}
(get-my-uri "http://google.com"))
result1 @f
;; sync
result2 (pm/exec commander {:timeout 1000 :error-fn println :fallback-fn (constantly "I feel lucky!")}
(get-my-uri "http://google.com"))])
Copyright © 2016 Oscaro.com
Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.
Can you improve this documentation? These fine people already did:
Nils Grunwald & Jérôme PrudentEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close