Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document types and arity of circuit breaker options #28

Open
marcomorain opened this issue Oct 11, 2019 · 1 comment
Open

Document types and arity of circuit breaker options #28

marcomorain opened this issue Oct 11, 2019 · 1 comment

Comments

@marcomorain
Copy link
Contributor

marcomorain commented Oct 11, 2019

First of all, thank you for diehard 🙏

I'm having a hard time setting up some of the circuit breaker options. In particular, the following keys are documented, but not what type the values should be. In particular, I don't know what the value should be for the following:

  • :delay-ms
  • :failure-threshold
  • :failure-threshold-ratio
  • :success-threshold
  • :success-threshold-ratio
  • :on-open
  • :on-close
  • :on-half-open

I assume that :on-open, :on-close, :on-half-open should be functions of artity 0.

Diehard docs: https://cljdoc.org/d/diehard/diehard/0.8.5/api/diehard.core#defcircuitbreaker

Define a circuit breaker with option.

Available options

There options are available when creating circuit breaker in
defcircuitbreaker.

Failure criteria

All the three fail options share same meaning with similar option in
retry block.

  • :fail-if
  • :fail-on
  • :fail-when
  • :timeout-ms while give all you code a timeout is best practice in
    application level, circuit breaker also provides a timeout for
    marking a long running block as failure
Delay and threshold
  • :delay-ms required. the delay for :open circuit breaker to turn
    into :half-open.
  • :failure-threshold
  • :failure-threshold-ratio
  • :success-threshold
  • :success-threshold-ratio All these four option is to determine at
    what condition the circuit breaker is open.
Listeners
  • :on-open a function to be called when state goes :open
  • :on-close a function to be called when state goes :closed
  • :on-half-open a function to be called when state goes :half-open

Failsafe docs: https://jodah.net/failsafe/circuit-breaker/#event-listeners

In addition to the standard policy listeners, a CircuitBreaker can notify you when the state of the breaker changes:

circuitBreaker
 .onOpen(() -> log.info("The circuit breaker was opened"))
 .onClose(() -> log.info("The circuit breaker was closed"))
 .onHalfOpen(() -> log.info("The circuit breaker was half-opened"));
@sunng87
Copy link
Owner

sunng87 commented Oct 15, 2019

Sorry for inconvenience. Could you please send a pull request for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants