K
- the key typepublic class KeyedCircuitBreakerMapping<K> extends java.lang.Object implements CircuitBreakerMapping
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.Modifier and Type | Class and Description |
---|---|
static interface |
KeyedCircuitBreakerMapping.KeySelector<K>
Returns the mapping key of the given
Request . |
Constructor and Description |
---|
KeyedCircuitBreakerMapping(KeyedCircuitBreakerMapping.KeySelector<K> keySelector,
java.util.function.Function<K,CircuitBreaker> factory)
Creates a new
KeyedCircuitBreakerMapping with the given KeyedCircuitBreakerMapping.KeySelector and
CircuitBreaker factory. |
Modifier and Type | Method and Description |
---|---|
CircuitBreaker |
get(ClientRequestContext ctx,
Request req)
Returns the
CircuitBreaker mapped to the given parameters. |
public KeyedCircuitBreakerMapping(KeyedCircuitBreakerMapping.KeySelector<K> keySelector, java.util.function.Function<K,CircuitBreaker> factory)
KeyedCircuitBreakerMapping
with the given KeyedCircuitBreakerMapping.KeySelector
and
CircuitBreaker
factory.keySelector
- A function that returns the key of the given Request
.factory
- A function that takes a key and creates a new CircuitBreaker
for the key.public CircuitBreaker get(ClientRequestContext ctx, Request req) throws java.lang.Exception
CircuitBreakerMapping
CircuitBreaker
mapped to the given parameters.get
in interface CircuitBreakerMapping
java.lang.Exception