Package

com.ccadllc.cedi

circuitbreaker

Permalink

package circuitbreaker

The circuitbreaker library provides protection against cascading failure and system overload via the CircuitBreaker and its primary function CircuitBreaker#protect. A CircuitBreakerRegistry maintains the collection of active circuit breakers and is the interface through which circuit breakers are created, retrieved, and removed and by which clients can subscribe for state change and statistics events related to the circuit breakers.

Source
package.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. circuitbreaker
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. sealed abstract class CircuitBreaker[F[_]] extends AnyRef

    Permalink

    The library's main abstraction, representing protection of an effectful program.

    The library's main abstraction, representing protection of an effectful program. The API is relatively simple, consisting of one primary function, protect, which takes the program to protect and returns that an enhanced version of that program having the ability to fail fast without invoking the underlying service if conditions warrant, ensuring failure of the service it represents does not result in a cascade of failure. The CircuitBreaker has two secondary functions: 1.) currentStatistics, which provides the current statistics.Statistics for use by monitoring and dashboarding applications and; 2.) lastActivity which provides the java.time.Instant timestamp indicating the instant the CircuitBreaker was last active.

    The CircuitBreaker is not generally directly instantiated; rather, a CircuitBreaker is requested from the CircuitBreakerRegistry via the CircuitBreakerRegistry#forFailure function which provides a variant that trips/opens given a configured percentage of protected program failures within a configured time period or via the CircuitBreakerRegistry#forFlowControl function which provides a variant that, in addition to the failure protected just described, also throttles requests when the average rate of requests over a configured time period is greater than the observed average rate of processing for the protected program.

    F

    - the type of effectful program.

  2. implicit final class CircuitBreakerOps[F[_], A] extends AnyVal

    Permalink

    Provides syntax enrichment on the effectful program F[A] so that one can write, for example, prg.protect(circuitBreaker) rather than circuitBreaker.protect(prg).

    Provides syntax enrichment on the effectful program F[A] so that one can write, for example, prg.protect(circuitBreaker) rather than circuitBreaker.protect(prg). This can lead to less awkward code under certain circumstances.

  3. final class CircuitBreakerRegistry[F[_]] extends AnyRef

    Permalink

    The circuit breaker registry maintains the non-persistent collection of CircuitBreakers created for a given virtual machine.

    The circuit breaker registry maintains the non-persistent collection of CircuitBreakers created for a given virtual machine. It provides the means to create and retrieve circuit breakers and to subscribe to fs2.Streams of statistics.Statistics and CircuitBreaker#CircuitBreakerEvent state change events. A CircuitBreakerRegistry instance is not directly instantiated but rather created via the smart constructor in the companion object. The effectful program types protected by the CircuitBreakers created and maintained with this registry are fixed by an F where an instance of Effect[F] is provided in implicit scope.

  4. case class FailureSettings(sampleWindow: SampleWindow, degradationThreshold: Percentage, test: Test, enabled: Boolean = true) extends Product with Serializable

    Permalink

    The configuration which controls the failure-based CircuitBreakers (that is, those circuit breakers which are created via the CircuitBreakerRegistry#forFailure function).

    The configuration which controls the failure-based CircuitBreakers (that is, those circuit breakers which are created via the CircuitBreakerRegistry#forFailure function).

    sampleWindow

    - the time-based window to be used to constrain the number of program execution success/failure indicators to store in order to determine the percentage of failures over this time period. An example would be SampleWindow(2.minutes) which means maintain the last two minutes of program execution success/failure indicators for a program protected by a given CircuitBreaker.

    degradationThreshold

    - the Percentage of items within the sample window which indicate program failure. For instance, if the percentage were Percentage(40.0) and there were 50 sample items in the 2 minute window, with 25 indicating program failure, then since 50% is greater than 40%, the circuit breaker would open.

    test

    - the testing configuration is used when the circuit breaker is open in order to determine how often a program should be executed rather than failed fast and then how many consecutively successful test executions need to occur in order to close the circuit breaker and allow normal operation of the protected program.

    enabled

    - The CircuitBreaker can be enabled or disabled with this parameter.

  5. case class FlowControlSettings(failure: FailureSettings, sampleWindow: SampleWindow, allowedOverProcessingRate: Percentage, minimumReportableRateChange: Percentage, perSecondRateMinimum: Long, perSecondRateHardLimit: Long, enabled: Boolean = true) extends Product with Serializable

    Permalink

    The configuration which controls the flow control-based CircuitBreakers (that is, those circuit breakers which are created via the CircuitBreakerRegistry#forFlowControl function).

    The configuration which controls the flow control-based CircuitBreakers (that is, those circuit breakers which are created via the CircuitBreakerRegistry#forFlowControl function).

    failure

    - the configuration for the failure component of the flow control CircuitBreaker. In addition to providing flow control, it also provides the same failure functionality as its failure-only variant.

    sampleWindow

    - the time-based window to be used to constrain the number of inbound program execution requests per second and program executions processed per second. The flow control circuit breaker maintains two separate collections (the inbound rate and the processing/completed rate) and both use this sample window configuration to constrain the sizes of these collections.

    allowedOverProcessingRate

    - the Percentage that the mean inbound rate is allowed to exceed the mean processing rate before this circuit breaker starts throttling inbound requests to lower it to an acceptable rate. Put another way, the acceptable rate is the processing rate + (processing rate * percentage / 100).

    minimumReportableRateChange

    - this is the percent that the calculated acceptable rate must be observed to have changed (either lower or higher) before a state change event is triggered. If it is 0, all state changes result in an event. This configuration item is meant to alleviate a flood of events when the request traffic pattern is very choppy (lots of spikes and valleys in a short time period).

    perSecondRateMinimum

    - this is the minimum observed inbound rate at which flow control throttling will kick in.

    perSecondRateHardLimit

    - this is the hard limit of the inbound requests per second above which requests will be throttled by the circuit breaker (failed fast without execution) for the remainder of the current second. It will be monitored and acted upon continuously.

    enabled

    - The flow control portion of the CircuitBreaker can be enabled or disabled with this parameter.

  6. case class Percentage(percent: Double) extends Product with Serializable

    Permalink

    Represents a percentage value, used throughout the library.

  7. case class RegistrySettings(garbageCollection: GarbageCollection) extends Product with Serializable

    Permalink

    The configuration used for the CircuitBreakerRegistry - it defines how often the registry should examine the CircuitBreakers under its control to remove instances which have been inactive longer than the configured cut-off time.

    The configuration used for the CircuitBreakerRegistry - it defines how often the registry should examine the CircuitBreakers under its control to remove instances which have been inactive longer than the configured cut-off time. If the checkInterval property of the RegistrySettings#GarbageCollection configuration item is set to a 0 value (e.g., 0.milliseconds), this feature will then be disabled.

  8. case class SampleWindow(duration: FiniteDuration, maximumEntries: Int = Int.MaxValue) extends Product with Serializable

    Permalink

    Represents a window of time, defined by the duration property and used to constrain the number of time-stamped sample items retained in order to calculate statistics for deriving CircuitBreaker state changes.

    Represents a window of time, defined by the duration property and used to constrain the number of time-stamped sample items retained in order to calculate statistics for deriving CircuitBreaker state changes. A hard limit of the number of samples is defined by the maximumEntries property.

Value Members

  1. object CircuitBreaker

    Permalink

    The companion object for a CircuitBreaker instance.

    The companion object for a CircuitBreaker instance. The smart constructors for creation of failure and flow control CircuitBreaker instances live here, as do common data types used by CircuitBreaker instances.

  2. object CircuitBreakerRegistry

    Permalink

    The companion object to the CircuitBreakerRegistry - contains a smart constructor for registry creation, optionally registering a garbage collector to reap CircuitBreakers managed by the registry when they have not been accessed for a configured period of time.

    The companion object to the CircuitBreakerRegistry - contains a smart constructor for registry creation, optionally registering a garbage collector to reap CircuitBreakers managed by the registry when they have not been accessed for a configured period of time. The companion also defines private data types used internally by the registry.

  3. object FailureSettings extends Serializable

    Permalink
  4. object FlowControlSettings extends Serializable

    Permalink
  5. object Percentage extends Serializable

    Permalink
  6. object RegistrySettings extends Serializable

    Permalink
  7. object SampleWindow extends Serializable

    Permalink
  8. package statistics

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped