Interface TypedGuard.Builder.CircuitBreakerBuilder<T>
- Enclosing interface:
TypedGuard.Builder<T>
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondelay(long value, ChronoUnit unit) Sets the delay after which an open circuit moves to half-open.done()Returns the original fault tolerance builder.Equivalent tofailOn(Set.of(value)).failOn(Collection<Class<? extends Throwable>> value) Sets the set of exception types considered failure.failureRatio(double value) Sets the failure ratio that, once reached, will move a closed circuit breaker to open.Sets a circuit breaker name.Sets a callback that will be invoked when this circuit breaker treats a finished invocation as failure.onPrevented(Runnable callback) Sets a callback that will be invoked when this circuit breaker prevents an invocation, because it is in the open or half-open state.onStateChange(Consumer<CircuitBreakerState> callback) Sets a callback that will be invoked upon each state change of this circuit breaker.Sets a callback that will be invoked when this circuit breaker treats a finished invocation as success.requestVolumeThreshold(int value) Sets the size of the circuit breaker's rolling window.Equivalent toskipOn(Set.of(value)).skipOn(Collection<Class<? extends Throwable>> value) Sets the set of exception types considered success.successThreshold(int value) Sets the number of successful executions that, once reached, will move a half-open circuit breaker to closed.Sets a predicate to determine when an exception should be considered failure by the circuit breaker.with(Consumer<TypedGuard.Builder.CircuitBreakerBuilder<T>> consumer)
-
Method Details
-
failOn
Sets the set of exception types considered failure. Defaults to all exceptions (Throwable).- Parameters:
value- collection of exception types, must not benull- Returns:
- this circuit breaker builder
- See Also:
-
failOn
Equivalent tofailOn(Set.of(value)).- Parameters:
value- an exception class, must not benull- Returns:
- this circuit breaker builder
-
skipOn
Sets the set of exception types considered success. Defaults to no exception (empty set).- Parameters:
value- collection of exception types, must not benull- Returns:
- this circuit breaker builder
- See Also:
-
skipOn
Equivalent toskipOn(Set.of(value)).- Parameters:
value- an exception class, must not benull- Returns:
- this circuit breaker builder
-
when
Sets a predicate to determine when an exception should be considered failure by the circuit breaker. This is a more general variant offailOn. Note that there is no generalizedskipOn, because all exceptions that do not match this predicate are implicitly considered success.If this method is called,
failOnandskipOnmay not be called.- Parameters:
value- the predicate, must not benull- Returns:
- this circuit breaker builder
-
delay
Sets the delay after which an open circuit moves to half-open. Defaults to 5 seconds.- Parameters:
value- the delay length, must be >= 0unit- the delay unit, must not benull- Returns:
- this circuit breaker builder
- See Also:
-
requestVolumeThreshold
Sets the size of the circuit breaker's rolling window.- Parameters:
value- the size of the circuit breaker's rolling window, must be >= 1- Returns:
- this circuit breaker builder
- See Also:
-
failureRatio
Sets the failure ratio that, once reached, will move a closed circuit breaker to open. Defaults to 0.5.- Parameters:
value- the failure ratio, must be >= 0 and <= 1- Returns:
- this circuit breaker builder
- See Also:
-
successThreshold
Sets the number of successful executions that, once reached, will move a half-open circuit breaker to closed. Defaults to 1.- Parameters:
value- the number of successful executions, must be >= 1- Returns:
- this circuit breaker builder
- See Also:
-
name
Sets a circuit breaker name. Required to use theCircuitBreakerMaintenancemethods. Defaults to unnamed. It is an error to use the same name for multiple circuit breakers.If a circuit breaker is not given a name, its state will not be affected by
CircuitBreakerMaintenance.resetAll(). This is unlike unnamed circuit breakers declared using@CircuitBreaker, because there's a fixed number of circuit breakers created using the declarative API, but a potentially unbounded number of circuit breakers created using the programmatic API. In other words, automatically remembering all circuit breakers created using the programmatic API would easily lead to a memory leak.- Parameters:
value- the circuit breaker name, must not benull- Returns:
- this circuit breaker builder
- See Also:
-
onStateChange
Sets a callback that will be invoked upon each state change of this circuit breaker.The callback must be fast and non-blocking and must not throw an exception.
- Parameters:
callback- the state change callback, must not benull- Returns:
- this circuit breaker builder
-
onSuccess
Sets a callback that will be invoked when this circuit breaker treats a finished invocation as success.The callback must be fast and non-blocking and must not throw an exception.
- Parameters:
callback- the success callback, must not benull- Returns:
- this circuit breaker builder
-
onFailure
Sets a callback that will be invoked when this circuit breaker treats a finished invocation as failure.The callback must be fast and non-blocking and must not throw an exception.
- Parameters:
callback- the failure callback, must not benull- Returns:
- this circuit breaker builder
-
onPrevented
Sets a callback that will be invoked when this circuit breaker prevents an invocation, because it is in the open or half-open state.The callback must be fast and non-blocking and must not throw an exception.
- Parameters:
callback- the prevented callback, must not benull- Returns:
- this circuit breaker builder
-
done
TypedGuard.Builder<T> done()Returns the original fault tolerance builder.- Returns:
- the original fault tolerance builder
-
with
default TypedGuard.Builder.CircuitBreakerBuilder<T> with(Consumer<TypedGuard.Builder.CircuitBreakerBuilder<T>> consumer)
-