1 package net.secodo.jcircuitbreaker.breakstrategy; 2 3 import net.secodo.jcircuitbreaker.breaker.execution.ExecutionContext; 4 import net.secodo.jcircuitbreaker.task.Task; 5 6 7 /** 8 * Break strategy defines if the circuit breaker should "break". When the "break" occurs <i>real-method</i> is not 9 * executed and such situation is handled by break handler. 10 * 11 * @param <R> the return type of the real method executed by the breaker 12 */ 13 public interface BreakStrategy<R> { 14 /** 15 * Returns true if "break" should happen, so that the Task (target-method) does not execute and circuit 16 * breaker executes fallback break handler. 17 * 18 * @param task the task for execution of which this <i>break strategy</i> was called 19 * @param executionContext current execution context 20 * 21 * @return true if the "break" should happen 22 */ 23 boolean shouldBreak(Task<R> task, ExecutionContext<R> executionContext); 24 }