java.lang.Object
com.linecorp.armeria.client.circuitbreaker.AbstractCircuitBreakerClientBuilder<I,O>
- Type Parameters:
I
- the type of incomingRequest
of theClient
O
- the type of incomingResponse
of theClient
- Direct Known Subclasses:
CircuitBreakerClientBuilder
,CircuitBreakerRpcClientBuilder
public abstract class AbstractCircuitBreakerClientBuilder<I extends Request,O extends Response>
extends Object
A skeletal builder implementation that builds a new
AbstractCircuitBreakerClient
or
its decorator function.-
Method Summary
Modifier and TypeMethodDescriptionhandler
(CircuitBreakerClientHandler handler) Sets theCircuitBreakerClientHandler
.mapping
(CircuitBreakerMapping mapping) Sets theCircuitBreakerMapping
.recover
(BiFunction<? super ClientRequestContext, ? super I, ? extends O> fallback) Sets theBiFunction
.
-
Method Details
-
mapping
Sets theCircuitBreakerMapping
. If unspecified,CircuitBreakerMapping.ofDefault()
will be used. Note that theCircuitBreakerClientHandler
set by callinghandler(CircuitBreakerClientHandler)
will be overwritten by calling this method.- Returns:
this
to support method chaining.
-
handler
@UnstableApi public AbstractCircuitBreakerClientBuilder<I,O> handler(CircuitBreakerClientHandler handler) Sets theCircuitBreakerClientHandler
. Note that theCircuitBreakerMapping
set by callingmapping(CircuitBreakerMapping)
will be overwritten by calling this method.- Returns:
this
to support method chaining.
-
recover
@UnstableApi public AbstractCircuitBreakerClientBuilder<I,O> recover(BiFunction<? super ClientRequestContext, ? super I, ? extends O> fallback) Sets theBiFunction
. This is invoked when adding the fallback strategy.For example:
CircuitBreakerClient .builder(...) .recover((ctx, req) -> { // fallback logic return HttpResponse.of(...); });
- Returns:
this
to support method chaining.
-