Example #1
0
        public CircuitBreaker(CircuitPolicy policy    = null,
                              ICircuitInvoker invoker = null,
                              Action <CircuitBreaker, Exception> onFailure         = null,
                              Action <CircuitBreaker, CircuitStatus> onStateChange = null)
        {
            _onFailure     = onFailure;
            _onStateChange = onStateChange;

            _policy = policy ?? CircuitPolicy.DefaultPolicy;

            invoker = invoker ?? DefaultInvoker;

            _closedState   = new ClosedState(this, _policy, invoker);
            _halfOpenState = new HalfOpenState(this, _policy, invoker);
            _openState     = new OpenState(this, _policy, invoker);

            _currentState = _closedState;
        }
Example #2
0
 public CircuitState(CircuitBreaker circuitBreaker, CircuitPolicy policy, ICircuitInvoker invoker)
 {
     _policy         = policy;
     _invoker        = invoker;
     _circuitBreaker = circuitBreaker;
 }
Example #3
0
 public OpenState(CircuitBreaker circuitBreaker, CircuitPolicy policy, ICircuitInvoker invoker)
     : base(circuitBreaker, policy, invoker)
 {
 }