Class CircuitBreaker$

java.lang.Object
org.apache.pekko.pattern.CircuitBreaker$

public class CircuitBreaker$ extends Object
Companion object providing factory methods for Circuit Breaker which runs callbacks in caller's thread
  • Field Details

    • MODULE$

      public static final CircuitBreaker$ MODULE$
      Static reference to the singleton instance of this Scala object.
  • Constructor Details

    • CircuitBreaker$

      public CircuitBreaker$()
  • Method Details

    • apply

      public CircuitBreaker apply(Scheduler scheduler, int maxFailures, scala.concurrent.duration.FiniteDuration callTimeout, scala.concurrent.duration.FiniteDuration resetTimeout)
      Create a new CircuitBreaker.

      Callbacks run in caller's thread when using withSyncCircuitBreaker, and in same ExecutionContext as the passed in Future when using withCircuitBreaker. To use another ExecutionContext for the callbacks you can specify the executor in the constructor.

      Parameters:
      scheduler - Reference to Pekko scheduler
      maxFailures - Maximum number of failures before opening the circuit
      callTimeout - FiniteDuration of time after which to consider a call a failure
      resetTimeout - FiniteDuration of time after which to attempt to close the circuit
    • apply

      public CircuitBreaker apply(String id, ExtendedActorSystem system)
      Create or find a CircuitBreaker in registry.

      Parameters:
      id - Circuit Breaker identifier
      system - ExtendedActorSystem that is storing this CircuitBreaker
    • create

      public CircuitBreaker create(Scheduler scheduler, int maxFailures, Duration callTimeout, Duration resetTimeout)
      Java API: Create a new CircuitBreaker.

      Callbacks run in caller's thread when using withSyncCircuitBreaker, and in same ExecutionContext as the passed in Future when using withCircuitBreaker. To use another ExecutionContext for the callbacks you can specify the executor in the constructor.

      Parameters:
      scheduler - Reference to Pekko scheduler
      maxFailures - Maximum number of failures before opening the circuit
      callTimeout - Duration of time after which to consider a call a failure
      resetTimeout - Duration of time after which to attempt to close the circuit
    • lookup

      public CircuitBreaker lookup(String id, ExtendedActorSystem system)
      Java API: Lookup a CircuitBreaker in registry.

      Parameters:
      id - Circuit Breaker identifier
      system - ExtendedActorSystem that is storing this CircuitBreaker
    • convertJavaFailureFnToScala

      protected <T> scala.Function1<scala.util.Try<T>,Object> convertJavaFailureFnToScala(BiFunction<Optional<T>,Optional<Throwable>,Boolean> javaFn)