Skip to content

Document types and arity of circuit breaker options聽#28

Description

@marcomorain

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"));

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions