GithubHelp home page GithubHelp logo

joelittlejohn / clj-http-hystrix Goto Github PK

View Code? Open in Web Editor NEW
22.0 22.0 4.0 61 KB

A Clojure library to wrap clj-http requests as hystrix commands

License: Eclipse Public License 1.0

Clojure 99.35% Shell 0.65%
circuit-breaker clj-http clojure http-client hystrix microservices

clj-http-hystrix's People

Contributors

joelittlejohn avatar mtkp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

clj-http-hystrix's Issues

Invalid bad_request and exception_thrown events in case of client-error

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:

image

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.

User-Defined Defaults

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.