Beispiel #1
0
        // Internal constructor with a few extra arguments used by tests to inject mocks.
        internal CommandInvoker(
            MjolnirConfiguration config = null,
            IMjolnirLogFactory logFactory = null,
            IMetricEvents metricEvents = null,
            IBreakerExceptionHandler breakerExceptionHandler = null,
            IBulkheadInvoker bulkheadInvoker = null)
        {
            _config = config ?? new MjolnirConfiguration
            {
                IsEnabled = true,
                UseCircuitBreakers = false,
                IgnoreTimeouts = false
            };
            _logFactory = logFactory ?? new DefaultMjolnirLogFactory();
            _log = _logFactory.CreateLog<CommandInvoker>();
            if (_log == null)
            {
                throw new InvalidOperationException($"{nameof(IMjolnirLogFactory)} implementation returned null from {nameof(IMjolnirLogFactory.CreateLog)} for name {nameof(CommandInvoker)}, please make sure the implementation returns a non-null log for all calls to {nameof(IMjolnirLogFactory.CreateLog)}");
            }

            _metricEvents = metricEvents ?? new IgnoringMetricEvents();
            _breakerExceptionHandler = breakerExceptionHandler ?? new IgnoredExceptionHandler(new HashSet<Type>());

            _circuitBreakerFactory = new CircuitBreakerFactory(
                _metricEvents,
                new FailurePercentageCircuitBreakerConfig(_config),
                _logFactory);

            _bulkheadFactory = new BulkheadFactory(
                _metricEvents,
                _config,
                _logFactory);

            var breakerInvoker = new BreakerInvoker(_circuitBreakerFactory, _metricEvents, _breakerExceptionHandler);
            _bulkheadInvoker = bulkheadInvoker ?? new BulkheadInvoker(breakerInvoker, _bulkheadFactory, _metricEvents, _config);
        }
Beispiel #2
0
 public DiFactory(ICircuitBreakerFactory factory)
 {
     Cb = factory.CreateCircuitBreaker <DiFactory>();
 }
Beispiel #3
0
 public BreakerInvoker(ICircuitBreakerFactory circuitBreakerFactory, IMetricEvents metricEvents, IBreakerExceptionHandler ignoredExceptions)
 {
     _circuitBreakerFactory = circuitBreakerFactory ?? throw new ArgumentNullException(nameof(circuitBreakerFactory));
     _metricEvents          = metricEvents ?? throw new ArgumentNullException(nameof(metricEvents));
     _ignoredExceptions     = ignoredExceptions ?? throw new ArgumentNullException(nameof(ignoredExceptions));
 }
Beispiel #4
0
 public SqlServerFullDbHelper(IConnectionStringProvider cnnProvider, IDbContextInfoProvider contextInfoProvider, ICircuitBreakerStore circuitBreakerStore, ICircuitBreakerFactory circuitBreakerFactory, IExceptionLogger logger) : base(cnnProvider, contextInfoProvider, circuitBreakerStore, circuitBreakerFactory, logger)
 {
 }