Class/Object

org.squbs.streams.circuitbreaker

CircuitBreakerBidi

Related Docs: object CircuitBreakerBidi | package circuitbreaker

Permalink

class CircuitBreakerBidi[In, Out, Context] extends GraphStage[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)]]

A bidi GraphStage that is joined with a Flow to add Circuit Breaker functionality. When the joined Flow is having trouble responding in time or is responding with failures, then based on the provided settings, it short circuits the Flow: Instead of pushing an element to the joined Flow, it directly pushes down a Failure or a fallback response to downstream, given that there is downstream demand.

CircuitBreakerSettings.circuitBreakerState that keeps circuit breaker state. The user can select a CircuitBreakerState implementation that is right for the use case. Please note, in many scenarios, a CircuitBreakerState might need to be shared across materializations or even different streams. In such scenarios, make sure to select a CircuitBreakerState implementation that can work across materializations concurrently.

A CircuitBreakerSettings.fallback function provides an alternative response when circuit is OPEN.

The joined Flow pushes down a Try. By default, any Failure is considered a problem and causes the circuit breaker failure count to be incremented. However, CircuitBreakerSettings.failureDecider can be used to decide on if an element passed by the joined Flow is actually considered a failure. For instance, if Circuit Breaker is joined with an Akka HTTP flow, a Success Http Response with status code 500 internal server error should be considered a failure.

Emits when an element is available from the joined Flow or a short circuited element is available

Backpressures when the downstream backpressures

Completes when upstream completes

Cancels when downstream cancels

Please note, if the upstream does not control the throughput, then the throughput of the stream might temporarily increase once the circuit is OPEN: The downstream demand will be addressed with short circuit/fallback messages, which might (or might not) take less time than it takes the joined Flow to process an element. To eliminate this problem, a throttle can be applied specifically for circuit breaker related messages.

                       +------+
      (In, Context) ~> |      | ~> (In, Context)
                       | bidi |
(Try[Out], Context) <~ |      | <~ (Try[Out], Context)
                       +------+
In

the type of the elements pulled from the upstream along with the Context and pushed down to joined flow

Out

the type that's contained in a Try and pushed downstream along with the Context

Context

the type of the context that is carried around along with the elements. The context may be of any type that can be used to uniquely identify each element

Linear Supertypes
GraphStage[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)]], GraphStageWithMaterializedValue[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed], Graph[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CircuitBreakerBidi
  2. GraphStage
  3. GraphStageWithMaterializedValue
  4. Graph
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type Shape = BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)]

    Permalink
    Definition Classes
    Graph

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def addAttributes(attr: Attributes): Graph[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed]

    Permalink
    Definition Classes
    Graph
  5. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  6. def async: Graph[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed]

    Permalink
    Definition Classes
    Graph
  7. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. def createLogic(inheritedAttributes: Attributes): GraphStageLogic

    Permalink
    Definition Classes
    CircuitBreakerBidi → GraphStage
  9. final def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, NotUsed)

    Permalink
    Definition Classes
    GraphStage → GraphStageWithMaterializedValue
  10. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  13. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  15. def initialAttributes: Attributes

    Permalink
    Definition Classes
    CircuitBreakerBidi → GraphStageWithMaterializedValue
  16. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  17. final lazy val module: Module

    Permalink
    Definition Classes
    GraphStageWithMaterializedValue → Graph
  18. def named(name: String): Graph[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed]

    Permalink
    Definition Classes
    Graph
  19. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  20. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  21. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  22. val shape: BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)]

    Permalink
    Definition Classes
    CircuitBreakerBidi → Graph
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  24. def toString(): String

    Permalink
    Definition Classes
    CircuitBreakerBidi → AnyRef → Any
  25. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  26. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  27. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def withAttributes(attr: Attributes): Graph[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed]

    Permalink
    Definition Classes
    GraphStageWithMaterializedValue → Graph

Inherited from GraphStage[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)]]

Inherited from GraphStageWithMaterializedValue[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed]

Inherited from Graph[BidiShape[(In, Context), (In, Context), (Try[Out], Context), (Try[Out], Context)], NotUsed]

Inherited from AnyRef

Inherited from Any

Ungrouped