package fault.java;

import fault.java.circuit.BreakerConfig;
import fault.java.circuit.ICircuitBreaker;
import fault.java.circuit.DefaultCircuitBreaker;
import fault.java.messages.ScheduleMessage;
import fault.java.metrics.ActionMetrics;
import fault.java.metrics.IActionMetrics;

/**
 * Created by timbrooks on 11/13/14.
 */
public class ServiceExecutor {

    private final ICircuitBreaker circuitBreaker;
    private Thread managingThread;
    private ManagingRunnable managingRunnable;

    public ServiceExecutor(int poolSize) {
        IActionMetrics IActionMetrics = new ActionMetrics();

        BreakerConfig breakerConfig = new BreakerConfig.BreakerConfigBuilder().failureThreshold(20)
                .timePeriodInMillis(5000).build();
        this.circuitBreaker = new DefaultCircuitBreaker(IActionMetrics, breakerConfig);

        managingRunnable = new ManagingRunnable(poolSize, circuitBreaker, IActionMetrics);
        managingThread = new Thread(managingRunnable, "Action Managing Thread");
        managingThread.start();
    }

    public <T> ResilientPromise<T> performAction(final ResilientAction<T> action, int millisTimeout) {
        if (circuitBreaker.isOpen()) {
            throw new RuntimeException("Circuit is Open");
        }
        long relativeTimeout = millisTimeout + 1 + System.currentTimeMillis();
        final ResilientPromise<T> resilientPromise = new ResilientPromise<>();

        ScheduleMessage<T> e = new ScheduleMessage<>(action, resilientPromise, relativeTimeout);
        managingRunnable.submit(e);

        return resilientPromise;
    }

    public void shutdown() {
        managingRunnable.shutdown();
        managingThread.interrupt();
    }

}

@@ -536,30 +536,100 @@
         
-IActionMetrics
+this(poolSize, new ActionMetrics());%0A    %7D%0A%0A    public ServiceExecutor(int poolSize,
  IAction
@@ -640,15 +640,9 @@
 ics 
-= new A
+a
 ctio
@@ -649,20 +649,19 @@
 nMetrics
-();%0A
+) %7B
 %0A       
@@ -665,37 +665,78 @@
     
-BreakerConfig breakerConfig =
+this(poolSize, actionMetrics, new DefaultCircuitBreaker(actionMetrics,
  new
@@ -847,98 +847,169 @@
 ld()
+))
 ;%0A    
+%7D%0A%0A
     
-this.circuitBreaker = new DefaultCircuitBreaker(IActionMetrics, breakerConfig);%0A
+public ServiceExecutor(int poolSize, IActionMetrics actionMetrics, ICircuitBreaker circuitBreaker) %7B%0A        this.circuitBreaker = circuitBreaker;
 %0A   
@@ -1079,18 +1079,17 @@
 reaker, 
-IA
+a
 ctionMet

Add multiple service executor constructors to pass in parameters