Beispiel #1
0
        /// <summary>
        /// Initialises a new circuit breaker using the supplied settings with a nested resiliency pattern invoker.
        /// </summary>
        /// <param name="settings">Settings to configure the circuit breaker.</param>
        /// <param name="nestedInvoker">The invoker to pass the command onto.</param>
        public CircuitBreaker(CircuitBreakerSettings settings, ResiliencyCommandInvoker nestedInvoker)
        {
            if (settings == null)
            {
                settings = new CircuitBreakerSettings();
            }
            var parameters = new CircuitBreakerStateParameters
            {
                settings = settings,
                invoker  = nestedInvoker
            };

            this.stateMachine       = new CircuitBreakerStateMachineImpl(new CircuitBreakerStateNormal(parameters));
            parameters.stateMachine = this.stateMachine;
            this.AttachToStateChangeEvent();
        }
 internal CircuitBreakerStateAttempt(CircuitBreakerStateParameters parameters)
 {
     this.parameters = parameters;
     this.semaphore  = new SemaphoreSuperSlim(1);
 }
 internal CircuitBreakerStateNormal(CircuitBreakerStateParameters parameters)
 {
     this.parameters = parameters;
     this.InitialiseResetTimer();
 }
 internal CircuitBreakerStateTripped(CircuitBreakerStateParameters parameters)
 {
     this.parameters = parameters;
     this.resetTimer = new Timer(this.ResetCallback, null, this.parameters.settings.TripWaitPeriod, infinity);
 }