Class CircuitBreakerClientBuilder
java.lang.Object
com.linecorp.armeria.client.circuitbreaker.AbstractCircuitBreakerClientBuilder<HttpRequest,HttpResponse>
com.linecorp.armeria.client.circuitbreaker.CircuitBreakerClientBuilder
public final class CircuitBreakerClientBuilder
extends AbstractCircuitBreakerClientBuilder<HttpRequest,HttpResponse>
Builds a new
CircuitBreakerClient
or its decorator function.-
Method Summary
Modifier and TypeMethodDescriptionbuild
(HttpClient delegate) Returns a newly-createdCircuitBreakerClient
based on the properties of this builder.handler
(CircuitBreakerClientHandler handler) Sets theCircuitBreakerClientHandler
.mapping
(CircuitBreakerMapping mapping) Sets theCircuitBreakerMapping
.Function<? super HttpClient,
CircuitBreakerClient> Returns a newly-created decorator that decorates anHttpClient
with a newCircuitBreakerClient
based on the properties of this builder.recover
(BiFunction<? super ClientRequestContext, ? super HttpRequest, ? extends HttpResponse> fallback) Sets theBiFunction
.
-
Method Details
-
build
Returns a newly-createdCircuitBreakerClient
based on the properties of this builder. -
newDecorator
Returns a newly-created decorator that decorates anHttpClient
with a newCircuitBreakerClient
based on the properties of this builder. -
mapping
Description copied from class:AbstractCircuitBreakerClientBuilder
Sets theCircuitBreakerMapping
. If unspecified,CircuitBreakerMapping.ofDefault()
will be used. Note that theCircuitBreakerClientHandler
set by callingAbstractCircuitBreakerClientBuilder.handler(CircuitBreakerClientHandler)
will be overwritten by calling this method.- Overrides:
mapping
in classAbstractCircuitBreakerClientBuilder<HttpRequest,
HttpResponse> - Returns:
this
to support method chaining.
-
handler
Description copied from class:AbstractCircuitBreakerClientBuilder
Sets theCircuitBreakerClientHandler
. Note that theCircuitBreakerMapping
set by callingAbstractCircuitBreakerClientBuilder.mapping(CircuitBreakerMapping)
will be overwritten by calling this method.- Overrides:
handler
in classAbstractCircuitBreakerClientBuilder<HttpRequest,
HttpResponse> - Returns:
this
to support method chaining.
-
recover
public CircuitBreakerClientBuilder recover(BiFunction<? super ClientRequestContext, ? super HttpRequest, ? extends HttpResponse> fallback) Description copied from class:AbstractCircuitBreakerClientBuilder
Sets theBiFunction
. This is invoked when adding the fallback strategy.For example:
CircuitBreakerClient .builder(...) .recover((ctx, req) -> { // fallback logic return HttpResponse.of(...); });
- Overrides:
recover
in classAbstractCircuitBreakerClientBuilder<HttpRequest,
HttpResponse> - Returns:
this
to support method chaining.
-