Interface CircuitBreakerConfig
- All Superinterfaces:
Prototype.Api, Prototype.Factory<CircuitBreaker>
- All Known Implementing Classes:
CircuitBreakerConfig.BuilderBase.CircuitBreakerConfigImpl
Configuration of a circuit breaker.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic classFluent API builder forCircuitBreaker.static classCircuitBreakerConfig.BuilderBase<BUILDER extends CircuitBreakerConfig.BuilderBase<BUILDER, PROTOTYPE>, PROTOTYPE extends CircuitBreakerConfig>Fluent API builder base forCircuitBreakerConfig. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDefault error ratio.static final intDefault success threshold.static final intDefault volume. -
Method Summary
Modifier and TypeMethodDescriptionapplyOn()These throwables will be considered failures.static CircuitBreakerConfig.Builderbuilder()Create a new fluent API builder to customize configuration.static CircuitBreakerConfig.Builderbuilder(CircuitBreakerConfig instance) Create a new fluent API builder from an existing instance.static CircuitBreakerConfigcreate()Create a new instance with default values.static CircuitBreakerConfigCreate a new instance from configuration.delay()How long to wait before transitioning from open to half-open state; must not be negative and must be small enough to represent in milliseconds.booleanFlag to enable metrics for this instance.intHow many failures out of 100 will trigger the circuit to open; must be between 1 and 100, inclusive, and its product with the configured volume must not exceed 2,147,483,647.executor()Executor service to schedule future tasks.name()Name of this circuit breaker.skipOn()These throwables will not be considered failures, all other will.intHow many successful calls will close a half-open circuit; must be at least 1.intvolume()Rolling window size used to calculate ratio of failed requests; must be at least 1 and its product with the configured error ratio must not exceed 2,147,483,647.Methods inherited from interface Prototype.Factory
buildModifier and TypeMethodDescriptionbuild()Create a new instance of the runtime type from this config object.
-
Field Details
-
DEFAULT_ERROR_RATIO
static final int DEFAULT_ERROR_RATIODefault error ratio.- See Also:
-
DEFAULT_SUCCESS_THRESHOLD
static final int DEFAULT_SUCCESS_THRESHOLDDefault success threshold.- See Also:
-
DEFAULT_VOLUME
static final int DEFAULT_VOLUMEDefault volume.- See Also:
-
-
Method Details
-
builder
Create a new fluent API builder to customize configuration.- Returns:
- a new builder
-
builder
Create a new fluent API builder from an existing instance.- Parameters:
instance- an existing instance used as a base for the builder- Returns:
- a builder based on an instance
-
create
Create a new instance from configuration.- Parameters:
config- used to configure the new instance- Returns:
- a new instance configured from configuration
-
create
Create a new instance with default values.- Returns:
- a new instance
-
name
-
delay
Duration delay()How long to wait before transitioning from open to half-open state; must not be negative and must be small enough to represent in milliseconds.- Returns:
- delay
-
errorRatio
int errorRatio()How many failures out of 100 will trigger the circuit to open; must be between 1 and 100, inclusive, and its product with the configured volume must not exceed 2,147,483,647. This is adapted to thevolume()used to handle the window of requests.If errorRatio is 40, and volume is 10, 4 failed requests will open the circuit. Default is 60.
- Returns:
- percent of failure that trigger the circuit to open
- See Also:
-
volume
int volume()Rolling window size used to calculate ratio of failed requests; must be at least 1 and its product with the configured error ratio must not exceed 2,147,483,647. Default is 10.- Returns:
- how big a window is used to calculate error errorRatio
- See Also:
-
successThreshold
int successThreshold()How many successful calls will close a half-open circuit; must be at least 1. Nevertheless, the first failed call will open the circuit again. Default is 1.- Returns:
- number of calls
-
executor
Optional<ExecutorService> executor()Executor service to schedule future tasks.- Returns:
- executor to use
-
skipOn
-
applyOn
-
enableMetrics
boolean enableMetrics()Flag to enable metrics for this instance. The value of this flag is combined with the global config entryFaultTolerance.FT_METRICS_DEFAULT_ENABLED. If either of these flags istrue, then metrics will be enabled for the instance.- Returns:
- metrics enabled flag
-