コード例 #1
0
        public CircuitBreak(int exceptionsAllowedBeforeBreaking, TimeSpan durationOfBreak, int reTries, Func <Exception, bool> exceptionPredicate)
        {
            logger = ObjectContainer.Resolve <Logging.ILogger>();

            circuitBreakerPolicy = Policy
                                   .Handle(exceptionPredicate)
                                   .CircuitBreaker(
                exceptionsAllowedBeforeBreaking: exceptionsAllowedBeforeBreaking,
                durationOfBreak: durationOfBreak,
                onBreak: (ex, breakDelay) =>
            {
                logger.LogError(".Breaker logging: Breaking the circuit for " + breakDelay.TotalMilliseconds + "ms!", ex);
            },
                onReset: () =>
            {
                logger.LogDebug(".Breaker logging: Call ok! Closed the circuit again.");
            },
                onHalfOpen: () =>
            {
                logger.LogDebug(".Breaker logging: Half-open; next call is a trial.");
            });


            retryPolicy = Policy
                          .Handle(exceptionPredicate)
                          .Retry(reTries);
        }
コード例 #2
0
ファイル: ImapStream.cs プロジェクト: webrot/Kooboo
        private void LogRead(string line)
        {
            if (String.IsNullOrEmpty(line))
            {
                return;
            }

            _logger.LogDebug($"{_remote.Address} C: " + line);
        }
コード例 #3
0
 private void LogRead(string line)
 {
     _logger.LogDebug("C: " + line);
 }