|
20 | 20 | :hystrix/threads |
21 | 21 | :hystrix/queue-size |
22 | 22 | :hystrix/timeout-ms |
| 23 | + :hystrix/breaker-request-volume |
| 24 | + :hystrix/breaker-error-percent |
| 25 | + :hystrix/breaker-sleep-window-ms |
23 | 26 | :hystrix/bad-request-pred}) |
24 | 27 |
|
25 | 28 | (defn default-fallback [req resp] |
|
63 | 66 | (.withCoreSize threads) |
64 | 67 | (.withMaxQueueSize (:hystrix/queue-size config 5)) |
65 | 68 | (.withQueueSizeRejectionThreshold (:hystrix/queue-size config 5)))] |
66 | | - (-> (HystrixCommand$Setter/withGroupKey (group-key group)) |
67 | | - (.andCommandKey (command-key (:hystrix/command-key config :default))) |
68 | | - (.andCommandPropertiesDefaults command-configurator) |
69 | | - (.andThreadPoolPropertiesDefaults thread-pool-configurator)))) |
| 69 | + (doto (HystrixCommand$Setter/withGroupKey (group-key group)) |
| 70 | + (.andCommandKey (command-key (:hystrix/command-key config :default))) |
| 71 | + (.andCommandPropertiesDefaults command-configurator) |
| 72 | + (.andThreadPoolPropertiesDefaults thread-pool-configurator)))) |
70 | 73 |
|
71 | 74 | (defn ^:private log-error [command-name ^HystrixCommand context] |
72 | 75 | (let [message (format "Failed to complete %s %s" command-name (.getExecutionEvents context))] |
|
101 | 104 | :message "Bad request pred" |
102 | 105 | :stack-trace (stack-trace)}))) |
103 | 106 | resp)) |
104 | | - wrap-exception-reponse (fn [resp] ((http/wrap-exceptions (constantly resp)) (assoc req :throw-exceptions true))) |
| 107 | + wrap-exception-response (fn [resp] ((http/wrap-exceptions (constantly resp)) (assoc req :throw-exceptions true))) |
105 | 108 | ^HystrixCommand$Setter configurator (configurator req) |
106 | 109 | logging-context (or (MDC/getCopyOfContextMap) {}) |
107 | 110 | command (proxy [HystrixCommand] [configurator] |
|
117 | 120 | (assoc :throw-exceptions false) |
118 | 121 | f |
119 | 122 | wrap-bad-request |
120 | | - wrap-exception-reponse)))] |
| 123 | + wrap-exception-response)))] |
121 | 124 | (handle-exception #(.execute command) req)) |
122 | 125 | (f req))) |
123 | 126 |
|
124 | | -(defn add-hook [] |
| 127 | +(defn add-hook |
125 | 128 | "Activate clj-http-hystrix to wrap all clj-http client requests as |
126 | 129 | hystrix commands." |
127 | | - (when (not (some-> (meta http/request) :robert.hooke/hooks deref (contains? #'wrap-hystrix))) |
| 130 | + [] |
| 131 | + (when-not (some-> (meta http/request) :robert.hooke/hooks deref (contains? #'wrap-hystrix)) |
128 | 132 | (hooke/add-hook #'http/request #'wrap-hystrix))) |
0 commit comments