Package io.smallrye.faulttolerance.api
Interface CircuitBreakerMaintenance
@Experimental("first attempt at providing maintenance access to circuit breakers")
public interface CircuitBreakerMaintenance
Allows reading and observing current state of circuit breakers and resetting them to the initial (closed) state.
To access a specific circuit breaker, it must be given a name using
@CircuitBreakerName
or withCircuitBreaker().name("...").-
Method Summary
Modifier and TypeMethodDescriptioncurrentState(String name) Returns current state of the circuit breaker with givenname.static CircuitBreakerMaintenanceget()Returns aCircuitBreakerMaintenanceinstance that provides maintenance access to existing circuit breakers.voidonStateChange(String name, Consumer<CircuitBreakerState> callback) Registers acallbackto be called when the circuit breaker with givennamechanges state.voidResets the circuit breaker with givennameto the initial (closed) state.voidresetAll()Resets all circuit breakers in the application to the initial (closed) state.
-
Method Details
-
get
Returns aCircuitBreakerMaintenanceinstance that provides maintenance access to existing circuit breakers. -
currentState
Returns current state of the circuit breaker with givenname. Note that there's no guarantee that the circuit breaker will stay in that state for any time, so this method is only useful for monitoring.It is an error to use a
namethat wasn't registered using@CircuitBreakerNameorwithCircuitBreaker().name("..."). -
onStateChange
Registers acallbackto be called when the circuit breaker with givennamechanges state.It is an error to use a
namethat wasn't registered using@CircuitBreakerNameorwithCircuitBreaker().name("...").The callback must be fast and non-blocking and must not throw an exception.
-
reset
Resets the circuit breaker with givennameto the initial (closed) state.This method should not be used regularly, it's mainly meant for testing (to isolate individual tests) and perhaps emergency maintenance tasks.
It is an error to use a
namethat wasn't registered using@CircuitBreakerNameorwithCircuitBreaker().name("..."). -
resetAll
void resetAll()Resets all circuit breakers in the application to the initial (closed) state. This includes all named circuit breakers and unnamed circuit breakers declared using@CircuitBreaker. It does not include unnamed circuit breakers created using the programmatic API.This method should not be used regularly, it's mainly meant for testing (to isolate individual tests) and perhaps emergency maintenance tasks.
-