Class KeyedCircuitBreakerMapping<K>
java.lang.Object
com.linecorp.armeria.client.circuitbreaker.KeyedCircuitBreakerMapping<K>
- Type Parameters:
K
- the key type
- All Implemented Interfaces:
CircuitBreakerMapping
public final class KeyedCircuitBreakerMapping<K> extends Object implements CircuitBreakerMapping
A
CircuitBreakerMapping
that binds a CircuitBreaker
to its key. KeyedCircuitBreakerMapping.KeySelector
is used
to resolve the key from a Request
. If there is no circuit breaker bound to the key, a new one is
created by using the given circuit breaker factory.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
KeyedCircuitBreakerMapping.KeySelector<K>
Returns the mapping key of the givenRequest
. -
Constructor Summary
Constructors Constructor Description KeyedCircuitBreakerMapping(KeyedCircuitBreakerMapping.KeySelector<K> keySelector, Function<K,CircuitBreaker> factory)
Creates a newKeyedCircuitBreakerMapping
with the givenKeyedCircuitBreakerMapping.KeySelector
andCircuitBreaker
factory. -
Method Summary
Modifier and Type Method Description CircuitBreaker
get(ClientRequestContext ctx, Request req)
Returns theCircuitBreaker
mapped to the given parameters.
-
Constructor Details
-
KeyedCircuitBreakerMapping
public KeyedCircuitBreakerMapping(KeyedCircuitBreakerMapping.KeySelector<K> keySelector, Function<K,CircuitBreaker> factory)Creates a newKeyedCircuitBreakerMapping
with the givenKeyedCircuitBreakerMapping.KeySelector
andCircuitBreaker
factory.- Parameters:
keySelector
- A function that returns the key of the givenRequest
.factory
- A function that takes a key and creates a newCircuitBreaker
for the key.
-
-
Method Details
-
get
Description copied from interface:CircuitBreakerMapping
Returns theCircuitBreaker
mapped to the given parameters.- Specified by:
get
in interfaceCircuitBreakerMapping
- Throws:
Exception
-