Contextual value represents circuit breaker name
Contextual value represents circuit breaker name
Contextual value represents event create time
Contextual value represents event create time
(circuit-breaker name)(circuit-breaker name config)Create a circuit breaker with a name and a default or custom circuit breaker configuration.
The name argument is only used to register this newly created circuit
breaker to a CircuitBreakerRegistry. If you don't want to bind this circuit
breaker with a CircuitBreakerRegistry, the name argument is ignored.
Please refer to circuit-breaker-config for allowed key value pairs
within the circuit breaker configurations map.
If you want to register this circuit breaker to a CircuitBreakerRegistry,
you need to put :registry key with a CircuitBreakerRegistry in the config
argument. If you do not provide any other configurations, the newly created
circuit breaker will inherit circuit breaker configurations from this
provided CircuitBreakerRegistry
Example:
(circuit-breaker my-breaker {:registry my-registry})
If you want to register this circuit breaker to a CircuitBreakerRegistry
and you want to use new circuit breaker configurations to overwrite the configurations
inherited from the registered CircuitBreakerRegistry,
you need not only provide the :registry key with the CircuitBreakerRegistry in config
argument but also provide other circuit breaker configurations you'd like to overwrite.
Example:
(circuit-breaker my-breaker {:registry my-registry
:failure-rate-threshold 50.0
:sliding-window-size 30
:permitted-number-of-calls-in-half-open-state 20})
If you only want to create a circuit breaker and not register it to any
CircuitBreakerRegistry, you just need to provide circuit breaker configurations in config
argument. The name argument is ignored.
Create a circuit breaker with a `name` and a default or custom circuit breaker configuration.
The `name` argument is only used to register this newly created circuit
breaker to a CircuitBreakerRegistry. If you don't want to bind this circuit
breaker with a CircuitBreakerRegistry, the `name` argument is ignored.
Please refer to `circuit-breaker-config` for allowed key value pairs
within the circuit breaker configurations map.
If you want to register this circuit breaker to a CircuitBreakerRegistry,
you need to put :registry key with a CircuitBreakerRegistry in the `config`
argument. If you do not provide any other configurations, the newly created
circuit breaker will inherit circuit breaker configurations from this
provided CircuitBreakerRegistry
Example:
(circuit-breaker my-breaker {:registry my-registry})
If you want to register this circuit breaker to a CircuitBreakerRegistry
and you want to use new circuit breaker configurations to overwrite the configurations
inherited from the registered CircuitBreakerRegistry,
you need not only provide the :registry key with the CircuitBreakerRegistry in `config`
argument but also provide other circuit breaker configurations you'd like to overwrite.
Example:
(circuit-breaker my-breaker {:registry my-registry
:failure-rate-threshold 50.0
:sliding-window-size 30
:permitted-number-of-calls-in-half-open-state 20})
If you only want to create a circuit breaker and not register it to any
CircuitBreakerRegistry, you just need to provide circuit breaker configurations in `config`
argument. The `name` argument is ignored.(circuit-breaker-config opts)Create a CircuitBreakerConfig.
Allowed options are:
:failure-rate-threshold Configures the failure rate threshold in percentage above which the circuit breaker should trip open and start short-circuiting calls. Must be a float/double. Default value is 50%.
:slow-call-rate-threshold Configures a threshold in percentage. The CircuitBreaker considers a call as slow when the call duration is greater than :slow-call-duration-threshold. When the percentage of slow calls is equal or greater the threshold, the CircuitBreaker transitions to open and starts short-circuiting calls. The threshold must be greater than 0 and not greater than 100. Default value is 100 percentage which means that all recorded calls must be slower than :slow-call-duration-threshold.
:writable-stack-trace-enabled Enables writable stack traces. When set to false, Exception#getStackTrace() returns a zero length array. This may be used to reduce log spam when the circuit breaker is open as the cause of the exceptions is already known (the circuit breaker is short-circuiting calls).
:wait-millis-in-open-state Configures the wait duration which specifies how long the circuit breaker should stay open, before it switches to half open. Default value is 60 seconds.
:wait-interval-function-in-open-state Configures an interval function which controls how long the CircuitBreaker should stay open, before it switches to half open. The default interval function returns a fixed wait duration of 60 seconds. A custom interval function is useful if you need an exponential backoff algorithm.
:slow-call-threshold-in-millis Configures the duration threshold in millis seconds above which calls are considered as slow and increase the slow calls percentage. Default value is 60 seconds.
:permitted-number-of-calls-in-half-open-state Configures the number of permitted calls when the CircuitBreaker is half open. The size must be greater than 0. Default size is 10.
:permitted-number-of-calls-in-half-open-state Configures the size of the ring buffer when the circuit breaker is half open. The circuit breaker stores the success/failure status of the latest calls in a ring buffer. For example, if :permitted-number-of-calls-in-half-open-state is 10, then at least 10 calls must be evaluated, before the failure rate can be calculated. If only 9 calls have been evaluated the CircuitBreaker will not trip back to closed or open even if all 9 calls have failed. The size must be greater than 0. Default size is 10.
:sliding-window-size Configures the size of the ring buffer when the circuit breaker is closed. The circuit breaker stores the success/failure status of the latest calls in a ring buffer. For example, if :sliding-window-size is 100, then at least 100 calls must be evaluated, before the failure rate can be calculated. If only 99 calls have been evaluated the circuit breaker will not trip open even if all 99 calls have failed. The default size is 100.
:sliding-window-size Configures the size of the sliding window which is used to record the outcome of calls when the CircuitBreaker is closed. :sliding-window-size configures the size of the sliding window. Sliding window can either be count-based or time-based. If :sliding-window-size is :COUNT_BASED, the last :sliding-window-size calls are recorded and aggregated. If :sliding-window-size is :TIME_BASED, the calls of the last :sliding-window-size seconds are recorded and aggregated. The :sliding-window-size must be greater than 0. The :minimum-number-of-calls must be greater than 0. If the slidingWindowType is :COUNT_BASED, the :minimum-number-of-calls cannot be greater than :sliding-window-size. If the slidingWindowType is :TIME_BASED, you can pick whatever you want. Default slidingWindowSize is 100.
:minimum-number-of-calls Configures configures the minimum number of calls which are required (per sliding window period) before the CircuitBreaker can calculate the error rate. For example, if :minimum-number-of-calls is 10, then at least 10 calls must be recorded, before the failure rate can be calculated. If only 9 calls have been recorded the circuit breaker will not transition to open even if all 9 calls have failed. Default minimumNumberOfCalls is 100.
:sliding-window-type Configures the type of the sliding window which is used to record the outcome of calls when the circuit breaker is closed. Sliding window can either be count-based or time-based. If :sliding-window-type is :COUNT_BASED, the last :sliding-window-size calls are recorded and aggregated. If :sliding-window-type is :TIME_BASED, the calls of the last :sliding-window-size seconds are recorded and aggregated. Default slidingWindowType is :COUNT_BASED.
:record-failure
Configures a function which take a throwable as argument and
evaluates if an exception should be recorded as a failure and thus
increase the failure rate.
The predicate function must return true if the exception should
count as a failure, otherwise it must return false.
:record-exception
Configures a function which take a throwable as argument and
evaluates if an exception should be recorded as a failure
and thus increase the failure rate.
The predicate function must return true if the exception should
count as a failure. The predicate function must return false, if the exception
should count as a success, unless the exception is explicitly ignored by
:ignore-exceptions or :ignore-exception configurations.
:ignore-exception
Configures a function which take a throwable as argument and
evaluates if an exception should be ignored and neither count as a
failure nor success.
The predicate function must return true if the exception should be ignored .
The predicate function must return false, if the exception should count as a failure.
:record-exceptions Configures a list of error classes that are recorded as a failure and thus increase the failure rate. Any exception matching or inheriting from one of the list should count as a failure, unless ignored via :ignore-exceptions. Ignoring an exception has priority over recording an exception. Example: {:record-exceptions [Throwable] :ignore-exceptions [RuntimeException]} would capture all Errors and checked Exceptions, and ignore unchecked exceptions. For a more sophisticated exception management use the :record-failure option.
:ignore-exceptions Configures a list of error classes that are ignored as a failure and thus do not increase the failure rate. Any exception matching or inheriting from one of the list will not count as a failure, even if marked via :record-exceptions. Ignoring an exception has priority over recording an exception. Example: {:ignore-exceptions [Throwable] :record-exceptions [Exception]} would capture nothing. Example: {:ignore-exceptions [Exception] :record-exceptions [Throwable]} would capture Errors. For a more sophisticated exception management use the :record-failure option.
:automatic-transfer-from-open-to-half-open? true to enable automatic transition from :OPEN to :HALF_OPEN state once the :wait-millis-in-open-state has passed.
Create a CircuitBreakerConfig.
Allowed options are:
* :failure-rate-threshold
Configures the failure rate threshold in
percentage above which the circuit breaker should trip open and start
short-circuiting calls.
Must be a float/double. Default value is 50%.
* :slow-call-rate-threshold
Configures a threshold in percentage. The CircuitBreaker considers a call
as slow when the call duration is greater than :slow-call-duration-threshold.
When the percentage of slow calls is equal or greater the threshold, the
CircuitBreaker transitions to open and starts short-circuiting calls.
The threshold must be greater than 0 and not greater than 100.
Default value is 100 percentage which means that all recorded calls must be
slower than :slow-call-duration-threshold.
* :writable-stack-trace-enabled
Enables writable stack traces. When set to false, Exception#getStackTrace()
returns a zero length array.
This may be used to reduce log spam when the circuit breaker is open as the
cause of the exceptions is already known (the circuit breaker is short-circuiting calls).
* :wait-millis-in-open-state
Configures the wait duration which specifies how long the
circuit breaker should stay open, before it switches to half
open.
Default value is 60 seconds.
* :wait-interval-function-in-open-state
Configures an interval function which controls how long the CircuitBreaker should stay
open, before it switches to half open. The default interval function returns a fixed wait
duration of 60 seconds.
A custom interval function is useful if you need an exponential backoff algorithm.
* :slow-call-threshold-in-millis
Configures the duration threshold in millis seconds above which calls are considered as slow and
increase the slow calls percentage.
Default value is 60 seconds.
* :permitted-number-of-calls-in-half-open-state
Configures the number of permitted calls when the CircuitBreaker is half open.
The size must be greater than 0. Default size is 10.
* :permitted-number-of-calls-in-half-open-state
Configures the size of the ring buffer when the circuit breaker
is half open. The circuit breaker stores the success/failure
status of the latest calls in a ring buffer. For example, if
:permitted-number-of-calls-in-half-open-state is 10, then at least 10 calls
must be evaluated, before the failure rate can be calculated. If
only 9 calls have been evaluated the CircuitBreaker will not trip
back to closed or open even if all 9 calls have failed.
The size must be greater than 0. Default size is 10.
* :sliding-window-size
Configures the size of the ring buffer when the circuit breaker is
closed. The circuit breaker stores the success/failure status of the
latest calls in a ring buffer. For example, if
:sliding-window-size is 100, then at least 100 calls
must be evaluated, before the failure rate can be calculated. If
only 99 calls have been evaluated the circuit breaker will not trip
open even if all 99 calls have failed.
The default size is 100.
* :sliding-window-size
Configures the size of the sliding window which is used to record the outcome
of calls when the CircuitBreaker is closed.
:sliding-window-size configures the size of the sliding window. Sliding window
can either be count-based or time-based.
If :sliding-window-size is :COUNT_BASED, the last :sliding-window-size calls are
recorded and aggregated.
If :sliding-window-size is :TIME_BASED, the calls of the last :sliding-window-size
seconds are recorded and aggregated.
The :sliding-window-size must be greater than 0.
The :minimum-number-of-calls must be greater than 0.
If the slidingWindowType is :COUNT_BASED, the :minimum-number-of-calls cannot be
greater than :sliding-window-size.
If the slidingWindowType is :TIME_BASED, you can pick whatever you want.
Default slidingWindowSize is 100.
* :minimum-number-of-calls
Configures configures the minimum number of calls which are required
(per sliding window period) before the CircuitBreaker can calculate the error rate.
For example, if :minimum-number-of-calls is 10, then at least 10 calls must be
recorded, before the failure rate can be calculated.
If only 9 calls have been recorded the circuit breaker will not transition to open
even if all 9 calls have failed.
Default minimumNumberOfCalls is 100.
* :sliding-window-type
Configures the type of the sliding window which is used to record the outcome of
calls when the circuit breaker is closed.
Sliding window can either be count-based or time-based.
If :sliding-window-type is :COUNT_BASED, the last :sliding-window-size calls are
recorded and aggregated.
If :sliding-window-type is :TIME_BASED, the calls of the last :sliding-window-size
seconds are recorded and aggregated.
Default slidingWindowType is :COUNT_BASED.
* :record-failure
Configures a function which take a `throwable` as argument and
evaluates if an exception should be recorded as a failure and thus
increase the failure rate.
The predicate function must return true if the exception should
count as a failure, otherwise it must return false.
* :record-exception
Configures a function which take a `throwable` as argument and
evaluates if an exception should be recorded as a failure
and thus increase the failure rate.
The predicate function must return true if the exception should
count as a failure. The predicate function must return false, if the exception
should count as a success, unless the exception is explicitly ignored by
:ignore-exceptions or :ignore-exception configurations.
* :ignore-exception
Configures a function which take a `throwable` as argument and
evaluates if an exception should be ignored and neither count as a
failure nor success.
The predicate function must return true if the exception should be ignored .
The predicate function must return false, if the exception should count as a failure.
* :record-exceptions
Configures a list of error classes that are recorded as a failure
and thus increase the failure rate. Any exception matching or
inheriting from one of the list should count as a failure, unless
ignored via :ignore-exceptions. Ignoring an exception has priority
over recording an exception.
Example:
{:record-exceptions [Throwable]
:ignore-exceptions [RuntimeException]}
would capture all Errors and checked Exceptions, and ignore
unchecked exceptions.
For a more sophisticated exception management use the
:record-failure option.
* :ignore-exceptions
Configures a list of error classes that are ignored as a failure
and thus do not increase the failure rate. Any exception matching
or inheriting from one of the list will not count as a failure,
even if marked via :record-exceptions. Ignoring an exception has
priority over recording an exception.
Example:
{:ignore-exceptions [Throwable]
:record-exceptions [Exception]}
would capture nothing.
Example:
{:ignore-exceptions [Exception]
:record-exceptions [Throwable]}
would capture Errors.
For a more sophisticated exception management use the
:record-failure option.
* :automatic-transfer-from-open-to-half-open?
true to enable automatic transition from :OPEN to :HALF_OPEN state once
the :wait-millis-in-open-state has passed.
(config breaker)Returns the configurations of this CircuitBreaker
Returns the configurations of this CircuitBreaker
(defbreaker name)(defbreaker name config)Define a circuit breaker under name with a default or custom circuit breaker
configuration.
Please refer to circuit-breaker-config for allowed key value pairs
within the circuit breaker configuration.
If you want to register this circuit breaker to a CircuitBreakerRegistry,
you need to put :registry key with a CircuitBreakerRegistry in the config
argument. If you do not provide any other configurations, the newly created
circuit breaker will inherit circuit breaker configurations from this
provided CircuitBreakerRegistry
Example:
(defbreaker my-breaker {:registry my-registry})
If you want to register this circuit breaker to a CircuitBreakerRegistry
and you want to use new circuit breaker configurations to overwrite the configurations
inherited from the registered CircuitBreakerRegistry,
you need not only provide the :registry key with the CircuitBreakerRegistry in config
argument but also provide other circuit breaker configurations you'd like to overwrite.
Example:
(defbreaker my-breaker {:registry my-registry
:failure-rate-threshold 50.0
:sliding-window-size 30
:permitted-number-of-calls-in-half-open-state 20})
If you only want to create a circuit breaker and not register it to any
CircuitBreakerRegistry, you just need to provide circuit breaker configuration in config
argument without :registry keyword.
Define a circuit breaker under `name` with a default or custom circuit breaker
configuration.
Please refer to `circuit-breaker-config` for allowed key value pairs
within the circuit breaker configuration.
If you want to register this circuit breaker to a CircuitBreakerRegistry,
you need to put :registry key with a CircuitBreakerRegistry in the `config`
argument. If you do not provide any other configurations, the newly created
circuit breaker will inherit circuit breaker configurations from this
provided CircuitBreakerRegistry
Example:
(defbreaker my-breaker {:registry my-registry})
If you want to register this circuit breaker to a CircuitBreakerRegistry
and you want to use new circuit breaker configurations to overwrite the configurations
inherited from the registered CircuitBreakerRegistry,
you need not only provide the :registry key with the CircuitBreakerRegistry in `config`
argument but also provide other circuit breaker configurations you'd like to overwrite.
Example:
(defbreaker my-breaker {:registry my-registry
:failure-rate-threshold 50.0
:sliding-window-size 30
:permitted-number-of-calls-in-half-open-state 20})
If you only want to create a circuit breaker and not register it to any
CircuitBreakerRegistry, you just need to provide circuit breaker configuration in `config`
argument without :registry keyword.(defregistry name)(defregistry name config)Define a CircuitBreakerRegistry under name with a default or custom
circuit breaker configuration.
Please refer to circuit-breaker-config for allowed key value pairs
within the circuit breaker configuration map.
Define a CircuitBreakerRegistry under `name` with a default or custom circuit breaker configuration. Please refer to `circuit-breaker-config` for allowed key value pairs within the circuit breaker configuration map.
(get-all-breakers registry)Get all circuit breakers registered to a CircuitBreakerRegistry
Get all circuit breakers registered to a CircuitBreakerRegistry
(metrics breaker)Get the Metrics of this CircuitBreaker
Get the Metrics of this CircuitBreaker
(name breaker)Get the name of this CircuitBreaker
Get the name of this CircuitBreaker
(on-error breaker duration-in-nanos throwable)Records a failed call. This method must be invoked when a call failed.
Records a failed call. This method must be invoked when a call failed.
(on-success breaker duration-in-nanos)Records a successful call.
Records a successful call.
(registry-with-config config)Create a CircuitBreakerRegistry with a circuit breaker configurations map.
Please refer to circuit-breaker-config for allowed key value pairs
within the circuit breaker configuration map.
Create a CircuitBreakerRegistry with a circuit breaker configurations map. Please refer to `circuit-breaker-config` for allowed key value pairs within the circuit breaker configuration map.
(reset! breaker)Get the circuit breaker to its original closed state, losing statistics. Should only be used, when you want to want to fully reset the circuit breaker without creating a new one.
Get the circuit breaker to its original closed state, losing statistics. Should only be used, when you want to want to fully reset the circuit breaker without creating a new one.
(set-on-call-not-permitted-consumer! breaker consumer-fn)(set-on-state-transition-event-consumer! breaker consumer-fn)(state breaker)Get the state of the circuit breaker in keyword format. Currently, state can be one of :DISABLED, :CLOSED, :OPEN, :FORCED_OPEN, :HALF_OPEN
Get the state of the circuit breaker in keyword format. Currently, state can be one of :DISABLED, :CLOSED, :OPEN, :FORCED_OPEN, :HALF_OPEN
(transition-to-closed-state! breaker)Transitions the circuit breaker state machine to CLOSED state.
Should only be used, when you want to force a state transition. State transition are normally done internally.
Transitions the circuit breaker state machine to CLOSED state. Should only be used, when you want to force a state transition. State transition are normally done internally.
(transition-to-disabled-state! breaker)Transitions the circut breaker state machine to a DISABLED state, stopping state transition, metrics and event publishing.
Should only be used, when you want to disable the circuit breaker allowing all calls to pass. To recover from this state you must force a new state transition
Transitions the circut breaker state machine to a DISABLED state, stopping state transition, metrics and event publishing. Should only be used, when you want to disable the circuit breaker allowing all calls to pass. To recover from this state you must force a new state transition
(transition-to-forced-open-state! breaker)Transitions the state machine to a FORCED_OPEN state, stopping state transition, metrics and event publishing.
Should only be used, when you want to disable the circuit breaker allowing no call to pass. To recover from this state you must force a new state transition.
Transitions the state machine to a FORCED_OPEN state, stopping state transition, metrics and event publishing. Should only be used, when you want to disable the circuit breaker allowing no call to pass. To recover from this state you must force a new state transition.
(transition-to-half-open! breaker)Transitions the circuit breaker state machine to HALF_OPEN state.
Should only be used, when you want to force a state transition. State transition are normally done internally.
Transitions the circuit breaker state machine to HALF_OPEN state. Should only be used, when you want to force a state transition. State transition are normally done internally.
(transition-to-open-state! breaker)Transitions the circuit breaker state machine to OPEN state.
Should only be used, when you want to force a state transition. State transition are normally done internally.
Transitions the circuit breaker state machine to OPEN state. Should only be used, when you want to force a state transition. State transition are normally done internally.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |