joelittlejohn / clj-http-hystrix Goto Github PK
View Code? Open in Web Editor NEWA Clojure library to wrap clj-http requests as hystrix commands
License: Eclipse Public License 1.0
A Clojure library to wrap clj-http requests as hystrix commands
License: Eclipse Public License 1.0
We use prometheus together with prometheus-hystrix in order to gather data for our Grafana dashboards and to trigger alarms in case something weird happens. Lately we also added some alarm triggers for our clojure projects that use clj-http-hystrix underneath.
As we use standard REST calls, HTTP status codes like 404 appear quite regularly. We noticed though that our clojure services (in opposite to the java services) trigger certain hystrix events ("bad_request" and "exception_thrown") that caused our Grafana dashboards to look quite bad:
I figured out that these Hystrix events are triggered due to HystrixBadRequestExceptions that are thrown here in case http/client-error?
returns false. I believe this is a wrong behaviour though, as the javdoc states:
NOTE: This should only be used when an error is due to user input such as IllegalArgumentException otherwise it defeats the purpose of fault-tolerance and fallback behavior.
Also there is a test in the hystrix' core library that indicates that this exception should be used for different purposes.
Add support for user-defined defaults. This would let users, for example, set a default timeout that will be the fallback if the value is not supplied, making global configuration much easier.
The defaults could be an optional argument when adding the hook:
;; specify different defaults for threads and timeout, via optional argument to add-hook
(clj-http-hystrix.core/add-hook {:hystrix/threads 8
:hystrix/timeout-ms 2500})
(clj-http/get "example.com" {:hystrix/command-key "example"})
;;=> {:hystrix/command-key "example"
;; :hystrix/threads 8
;; :hystrix/timeout-ms 2500
;; ... rest are clj-http-hystrix defaults... }
;; or instead, use clj-http-hytrix defaults (unchanged)
(clj-http-hystrix.core/add-hook)
@joelittlejohn I'm happy to tackle this if you think its a reasonable feature to add.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.