@Experimental public interface CircuitBreaker extends Closeable
This interface provides methods to track command metrics and manage circuit breaker state. Implementations must be thread-safe.
| Modifier and Type | Interface and Description |
|---|---|
static class |
CircuitBreaker.State |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(CircuitBreakerStateListener listener)
Add a listener for circuit breaker state change events.
|
void |
close() |
CircuitBreaker.State |
getCurrentState()
Get the current state of the circuit breaker.
|
io.lettuce.core.failover.CircuitBreakerGeneration |
getGeneration()
Get the current generation of the circuit breaker.
|
String |
getId()
Get the ID for this circuit breaker.
|
MetricsSnapshot |
getSnapshot()
Get a snapshot of the current metrics within the time window.
|
boolean |
isClosed()
Check if the circuit breaker is in the closed state.
|
void |
removeListener(CircuitBreakerStateListener listener)
Remove a listener for circuit breaker state change events.
|
void |
transitionTo(CircuitBreaker.State newState)
Transition the circuit breaker to the specified state.
|
String getId()
MetricsSnapshot getSnapshot()
io.lettuce.core.failover.CircuitBreakerGeneration getGeneration()
CircuitBreaker.State getCurrentState()
boolean isClosed()
true if the circuit breaker is in the closed statevoid transitionTo(CircuitBreaker.State newState)
newState - the target statevoid addListener(CircuitBreakerStateListener listener)
listener - the listener to add, must not be nullvoid removeListener(CircuitBreakerStateListener listener)
listener - the listener to remove, must not be nullvoid close()
close in interface AutoCloseableclose in interface CloseableCopyright © 2026 lettuce.io. All rights reserved.