Class FailureIsolator
java.lang.Object
com.tnsai.coordination.production.FailureIsolator
Cascading failure protection for multi-agent systems.
Implements per-agent circuit breakers with configurable degradation strategies.
Example usage:
FailureIsolator isolator = FailureIsolator.builder()
.failureThreshold(3)
.recoveryTimeout(Duration.ofSeconds(30))
.degradationStrategy(DegradationStrategy.FALLBACK)
.build();
String result = isolator.execute("agent-a", () -> agent.chat("Hello"),
() -> "Fallback response");
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classException thrown when FAIL_FAST strategy is used and circuit is open.static enumCircuit breaker states.static enumHow to handle failures when circuit is open. -
Method Summary
Modifier and TypeMethodDescriptionstatic FailureIsolator.Builderbuilder()<T> TExecutes an operation with circuit breaker protection.intfailureCount(String agentId) Returns failure count for an agent.voidManually resets the circuit for an agent.Returns the current circuit state for an agent.
-
Method Details
-
execute
Executes an operation with circuit breaker protection.- Parameters:
agentId- the agent identifieraction- the action to executefallback- fallback supplier (used when strategy is FALLBACK)- Returns:
- the result or fallback
-
state
Returns the current circuit state for an agent. -
reset
Manually resets the circuit for an agent. -
failureCount
Returns failure count for an agent. -
builder
-