Skip to content

Commit 373691d

Browse files
committed
Add more circuit breaker options
1 parent 191784c commit 373691d

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ When you start your app, add:
1515
Whenever you make an http request, add one or more of the hystrix-clj options to your options map:
1616

1717
```clj
18-
(http/get "http://www.google.com" {:hystrix/command-key :default
19-
:hystrix/fallback-fn default-fallback
20-
:hystrix/group-key :default
21-
:hystrix/threads 10
22-
:hystrix/queue-size 5
23-
:hystrix/timeout-ms 1000
18+
(http/get "http://www.google.com" {:hystrix/command-key :default
19+
:hystrix/fallback-fn default-fallback
20+
:hystrix/group-key :default
21+
:hystrix/threads 10
22+
:hystrix/queue-size 5
23+
:hystrix/timeout-ms 1000
24+
:hystrix/breaker-request-volume 20
25+
:hystrix/breaker-error-percent 50
26+
:hystrix/breaker-sleep-window-ms 5000
2427
:hystrix/bad-request-pred client-error?}}
2528
```
2629
Any values not supplied will be set to their default values as above. Requests with no Hystrix-related keys won't use Hystrix.

src/clj_http_hystrix/core.clj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,14 @@
5050
(let [timeout (:hystrix/timeout-ms config 1000)
5151
group (:hystrix/group-key config :default)
5252
threads (:hystrix/threads config 10)
53+
request-volume (:hystrix/breaker-request-volume config 20)
54+
error-percent (:hystrix/breaker-error-percent config 50)
55+
sleep-window (:hystrix/breaker-sleep-window-ms config 5000)
5356
command-configurator (doto (HystrixCommandProperties/Setter)
5457
(.withExecutionIsolationThreadTimeoutInMilliseconds timeout)
58+
(.withCircuitBreakerRequestVolumeThreshold request-volume)
59+
(.withCircuitBreakerErrorThresholdPercentage error-percent)
60+
(.withCircuitBreakerSleepWindowInMilliseconds sleep-window)
5561
(.withMetricsRollingPercentileEnabled false))
5662
thread-pool-configurator (doto (HystrixThreadPoolProperties/Setter)
5763
(.withCoreSize threads)

0 commit comments

Comments
 (0)