Interface CircuitBreakerRuleWithContent<T extends Response>
- Type Parameters:
T
- the response type
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Determines whether a
Response
should be reported as a success or failure to a
CircuitBreaker
using the content of the Response
. If you just need the HTTP headers
to make a decision, use CircuitBreakerRule
for efficiency.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T extends Response>
CircuitBreakerRuleWithContentBuilder<T>builder()
Returns a newly createdCircuitBreakerRuleWithContentBuilder
.static <T extends Response>
CircuitBreakerRuleWithContentBuilder<T>builder
(HttpMethod... methods) Returns a newly createdCircuitBreakerRuleWithContentBuilder
with the specifiedHttpMethod
s.static <T extends Response>
CircuitBreakerRuleWithContentBuilder<T>builder
(Iterable<HttpMethod> methods) Returns a newly createdCircuitBreakerRuleWithContentBuilder
with the specifiedHttpMethod
s.static <T extends Response>
CircuitBreakerRuleWithContentBuilder<T>builder
(BiPredicate<? super ClientRequestContext, ? super RequestHeaders> requestHeadersFilter) Returns a newly createdCircuitBreakerRuleWithContentBuilder
with the specifiedrequestHeadersFilter
.static <T extends Response>
CircuitBreakerRuleWithContent<T>of
(CircuitBreakerRuleWithContent<T>... circuitBreakerRules) Returns aCircuitBreakerRuleWithContent
that combines the specifiedCircuitBreakerRuleWithContent
s.static <T extends Response>
CircuitBreakerRuleWithContent<T>of
(Iterable<? extends CircuitBreakerRuleWithContent<T>> circuitBreakerRules) Returns aCircuitBreakerRuleWithContent
that combines the specifiedCircuitBreakerRuleWithContent
s.static <T extends Response>
CircuitBreakerRuleWithContent<T>onResponse
(BiFunction<? super ClientRequestContext, ? super T, ? extends CompletionStage<Boolean>> responseFilter) Returns a newly createdCircuitBreakerRuleWithContent
that will report aResponse
as a failure if the specifiedresponseFilter
completes withtrue
.default CircuitBreakerRuleWithContent<T>
orElse
(CircuitBreakerRule other) Returns a composedCircuitBreakerRuleWithContent
that represents a logical OR of thisCircuitBreakerRuleWithContent
and the specifiedCircuitBreakerRule
.default CircuitBreakerRuleWithContent<T>
orElse
(CircuitBreakerRuleWithContent<T> other) Returns a composedCircuitBreakerRuleWithContent
that represents a logical OR of thisCircuitBreakerRuleWithContent
and another.default boolean
Returns whether this rule requires the response trailers to determine if aResponse
is successful or not.shouldReportAsSuccess
(ClientRequestContext ctx, T response, @Nullable Throwable cause) Returns aCompletionStage
that contains aCircuitBreakerDecision
.
-
Method Details
-
onResponse
static <T extends Response> CircuitBreakerRuleWithContent<T> onResponse(BiFunction<? super ClientRequestContext, ? super T, ? extends CompletionStage<Boolean>> responseFilter) Returns a newly createdCircuitBreakerRuleWithContent
that will report aResponse
as a failure if the specifiedresponseFilter
completes withtrue
. -
builder
Returns a newly createdCircuitBreakerRuleWithContentBuilder
. -
builder
Returns a newly createdCircuitBreakerRuleWithContentBuilder
with the specifiedHttpMethod
s. -
builder
static <T extends Response> CircuitBreakerRuleWithContentBuilder<T> builder(Iterable<HttpMethod> methods) Returns a newly createdCircuitBreakerRuleWithContentBuilder
with the specifiedHttpMethod
s. -
builder
static <T extends Response> CircuitBreakerRuleWithContentBuilder<T> builder(BiPredicate<? super ClientRequestContext, ? super RequestHeaders> requestHeadersFilter) Returns a newly createdCircuitBreakerRuleWithContentBuilder
with the specifiedrequestHeadersFilter
. -
of
@SafeVarargs static <T extends Response> CircuitBreakerRuleWithContent<T> of(CircuitBreakerRuleWithContent<T>... circuitBreakerRules) Returns aCircuitBreakerRuleWithContent
that combines the specifiedCircuitBreakerRuleWithContent
s. -
of
static <T extends Response> CircuitBreakerRuleWithContent<T> of(Iterable<? extends CircuitBreakerRuleWithContent<T>> circuitBreakerRules) Returns aCircuitBreakerRuleWithContent
that combines the specifiedCircuitBreakerRuleWithContent
s. -
orElse
Returns a composedCircuitBreakerRuleWithContent
that represents a logical OR of thisCircuitBreakerRuleWithContent
and the specifiedCircuitBreakerRule
. If thisCircuitBreakerRuleWithContent
completes withCircuitBreakerDecision.next()
, then otherCircuitBreakerRule
is evaluated. -
orElse
Returns a composedCircuitBreakerRuleWithContent
that represents a logical OR of thisCircuitBreakerRuleWithContent
and another. If thisCircuitBreakerRuleWithContent
completes withCircuitBreakerDecision.next()
, then otherCircuitBreakerRuleWithContent
is evaluated. -
shouldReportAsSuccess
CompletionStage<CircuitBreakerDecision> shouldReportAsSuccess(ClientRequestContext ctx, @Nullable T response, @Nullable @Nullable Throwable cause) Returns aCompletionStage
that contains aCircuitBreakerDecision
. IfCircuitBreakerDecision.success()
is returned,CircuitBreaker.onSuccess()
is called so that theCircuitBreaker
increases its success count and uses it to make a decision to close or open the circuit. IfCircuitBreakerDecision.failure()
is returned, it works the other way around. IfCircuitBreakerDecision.ignore()
is returned, theCircuitBreaker
ignores it. IfCircuitBreakerDecision.next()
is returned, a nextCircuitBreakerRule
will be evaluated.Note that the last
CircuitBreakerRule
completes withCircuitBreakerDecision.next()
or aResponse
did not match the givenCircuitBreakerRule
s, theResponse
will be reported as a success.- Parameters:
ctx
- theClientRequestContext
of this request.response
- theResponse
from the server.null
if aThrowable
is raised before receiving the content of theResponse
.cause
- theThrowable
which is raised while sending a request and before receiving the content of theResponse
.null
if there's no exception.
-
requiresResponseTrailers
default boolean requiresResponseTrailers()Returns whether this rule requires the response trailers to determine if aResponse
is successful or not.
-