Interface CircuitBreakerBuilder
public interface CircuitBreakerBuilder
A builder for
CircuitBreaker.
Unlike CircuitBreaker.openHandler(Handler), CircuitBreaker.halfOpenHandler(Handler) and
CircuitBreaker.closeHandler(Handler), the handlers configured through this builder are baked in as
immutable when build() is called: calling the corresponding mutator method again on the built circuit
breaker throws an IllegalStateException.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()Build and return the circuit breaker.closeHandler(Handler<Void> handler) Set the handler invoked when the circuit breaker state switches to closed.failurePolicy(FailurePolicy<T> failurePolicy) Set the failure policy, seeCircuitBreaker.failurePolicy(FailurePolicy).Set the default fallback function, seeCircuitBreaker.fallback(Function).halfOpenHandler(Handler<Void> handler) Set the handler invoked when the circuit breaker state switches to half-open.openHandler(Handler<Void> handler) Set the handler invoked when the circuit breaker state switches to open.retryPolicy(RetryPolicy retryPolicy) Set the retry policy, seeCircuitBreaker.retryPolicy(RetryPolicy).with(CircuitBreakerOptions options) Configure the circuit breaker options.
-
Method Details
-
with
Configure the circuit breaker options.- Parameters:
options- the configuration options- Returns:
- a reference to this, so the API can be used fluently
-
openHandler
Set the handler invoked when the circuit breaker state switches to open.- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
halfOpenHandler
Set the handler invoked when the circuit breaker state switches to half-open.- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
closeHandler
Set the handler invoked when the circuit breaker state switches to closed.- Parameters:
handler- the handler- Returns:
- a reference to this, so the API can be used fluently
-
fallback
Set the default fallback function, seeCircuitBreaker.fallback(Function).- Parameters:
handler- the fallback function- Returns:
- a reference to this, so the API can be used fluently
-
failurePolicy
Set the failure policy, seeCircuitBreaker.failurePolicy(FailurePolicy).- Parameters:
failurePolicy- the failure policy- Returns:
- a reference to this, so the API can be used fluently
-
retryPolicy
Set the retry policy, seeCircuitBreaker.retryPolicy(RetryPolicy).- Parameters:
retryPolicy- the retry policy- Returns:
- a reference to this, so the API can be used fluently
-
build
CircuitBreaker build()Build and return the circuit breaker.- Returns:
- the circuit breaker as configured by this builder
-