Exemplo n.º 1
0
        /// <summary>
        /// Indicates that a recently-completed operation was successful.
        ///
        /// If the breaker is tripped and <code>MarkSuccess()</code> is called, the breaker will be fixed.
        /// The operation's elapsed duration (in milliseconds) is used to ensure the operation being checked
        /// began before the breaker was initially tripped.
        /// </summary>
        public void MarkSuccess(long elapsedMillis)
        {
            if (_state != State.Tripped || _clock.GetMillisecondTimestamp() - elapsedMillis < _lastTrippedTimestamp)
            {
                // Ignore.
                return;
            }

            _log.Info($"Fixed Breaker={_key}");

            _state = State.Fixed;
            _metrics.Reset();

            _metricEvents.BreakerFixed(Name);
        }
        /// <summary>
        /// Indicates that a recently-completed operation was successful.
        ///
        /// If the breaker is tripped and <code>MarkSuccess()</code> is called, the breaker will be fixed.
        /// The operation's elapsed duration (in milliseconds) is used to ensure the operation being checked
        /// began before the breaker was initially tripped.
        /// </summary>
        public void MarkSuccess(long elapsedMillis)
        {
            if (_state != State.Tripped || _clock.GetMillisecondTimestamp() - elapsedMillis < _lastTrippedTimestamp)
            {
                // Ignore.
                _stats.Event(StatsPrefix + " MarkSuccess", "Ignored", null);
                return;
            }

            Log.InfoFormat("Fixed Breaker={0}", _key);

            _state = State.Fixed;
            _metrics.Reset();

            _stats.Event(StatsPrefix + " MarkSuccess", "Fixed", null);
        }
Exemplo n.º 3
0
        public void MarkSuccess()
        {
            if (!ConfigSet.CircuitBreakerEnabled)
            {
                return;
            }

            if (OpenFlag)
            {
                OpenFlag.Value = false;
                Metrics.Reset();
                CommonUtils.Log.Log(
                    LogLevelEnum.Info,
                    "Circuit Breaker is closed after a command execution succeeded.",
                    new Dictionary <string, string>()
                {
                    { "CircuitBreaker", "Closed" }
                });
            }
        }