コード例 #1
0
 public static IHttpClient AddCircuitBreaking(
     this IHttpClient httpClient,
     IHttpApiWithCircuitBreaking httpApiWithCircuitBreaking,
     ICircuitBreakerManager circuitBreakerManager)
 {
     return(new CircuitBreakingHttpClient(
                httpClient,
                circuitBreakerManager.GetState(httpApiWithCircuitBreaking.CircuitBreakerPolicy)));
 }
コード例 #2
0
 public SmsMessageService(ILogger <SmsMessageService> logger,
                          ISmsMessageRepository repository,
                          ISmsNotification smsNotification,
                          IDateTimeProvider dateTimeProvider,
                          ICircuitBreakerManager circuitBreakerManager,
                          IDistributedLock distributedLock)
 {
     _logger                = logger;
     _repository            = repository;
     _smsNotification       = smsNotification;
     _dateTimeProvider      = dateTimeProvider;
     _circuitBreakerManager = circuitBreakerManager;
     _distributedLock       = distributedLock;
 }
コード例 #3
0
 public EmailMessageService(ILogger <EmailMessageService> logger,
                            IEmailMessageRepository repository,
                            IEmailNotification emailNotification,
                            IDateTimeProvider dateTimeProvider,
                            ICircuitBreakerManager circuitBreakerManager,
                            IDistributedLock distributedLock)
 {
     _logger                = logger;
     _repository            = repository;
     _emailNotification     = emailNotification;
     _dateTimeProvider      = dateTimeProvider;
     _circuitBreakerManager = circuitBreakerManager;
     _distributedLock       = distributedLock;
 }
コード例 #4
0
        public BetterController(ILogger <BetterController> logger, ICircuitBreakerManager circuitBreakerManager)
        {
            _logger = logger;
            _circuitBreakerManager = circuitBreakerManager;

            var policy = Policy.Handle <Exception>()
                         .AdvancedCircuitBreakerAsync(failureThreshold: 0.5,
                                                      samplingDuration: TimeSpan.FromMinutes(2),
                                                      minimumThroughput: 2,
                                                      durationOfBreak: TimeSpan.FromMinutes(5),
                                                      onBreak: (Exception e, TimeSpan span) =>
            {
                _logger.LogError("Policy did break");
            },
                                                      onReset: () =>
            {
                _logger.LogInformation("Policy did reset");
            });

            var isAdded = _circuitBreakerManager.TryAdd(PolicyName, policy); //True on the first request, False on subsequent requests

            _logger.LogInformation($"Has the policy been added? {isAdded.ToString()}");
        }
コード例 #5
0
 public IdealController(ILogger <IdealController> logger, ICircuitBreakerManager circuitBreakerManager)
 {
     _logger = logger;
     _circuitBreakerManager = circuitBreakerManager;
 }
コード例 #6
0
 public CircuitBreakerHostedService(ICircuitBreakerManager circuitBreakerManager)
 {
     _circuitBreakerManager = circuitBreakerManager;
 }
コード例 #7
0
 public ManagementController(ILogger <ManagementController> logger, ICircuitBreakerManager circuitBreakerManager)
 {
     _logger = logger;
     _circuitBreakerManager = circuitBreakerManager;
 }
コード例 #8
0
 public CircuitBreakerController(ICircuitBreakerManager circuitBreakerManager)
 {
     this.circuitBreakerManager = circuitBreakerManager;
 }
コード例 #9
0
 public CircuitBreakingHttpClientDecorator(ICircuitBreakerManager circuitBreakerManager)
 {
     _circuitBreakerManager = circuitBreakerManager;
 }
コード例 #10
0
 public CircuitBreakerStateCollector(ICircuitBreakerManager circuitBreakerManager)
 {
     _circuitBreakerManager = circuitBreakerManager;
 }