Open
Description
Currently, we have @CircuitBreaker
, which automatically (based on relatively simple criteria) provides a "fail fast" behavior. I propose to add general @FailFast
policy, which would delegate the "should fail fast?" decision to some handler. For example:
public class MyService {
@FailFast(MyServiceFailFastHandler.class)
public void someCostlyMethod() {
...
}
}
public class MyServiceFailFastHandler implements FailFastHandler {
public boolean shouldFailFast(FailFastContext ctx) {
...
}
}
The API would look something like this:
public @interface FailFast {
Class<? extends FailFastHandler> value();
}
public interface FailFastHandler {
boolean shouldFailFast(FailFastContext ctx);
}
// similar to existing `ExecutionContext`
//
// we could also use `ExecutionContext` unmodified,
// and specify that `getFailure` is always `null` (or throws an exception)
public interface FailFastContext {
Method getMethod();
Object[] getParameters();
}
// thrown when `FailFastHandler.shouldFailFast` returns `true`
public class FailFastException extends FaultToleranceException {
}
I didn't have much time to look into this yet, so I'm filing this issue just to gather some feedback.
Metadata
Metadata
Assignees
Labels
No labels