Exemple #1
0
        public async Task Invoke(HttpContext context)
        {
            if (this._resilenceService.CheckIfBreakerStateOpened)
            {
                throw new CircuitBreakerOpenedException(_resilenceService.LastHandledExceptionByCircuitBreaker.Message);
            }

            var command = new ExecuteThroughCircuitBreakerCommand(async() => await _next(context));

            await this._resilenceService
            .ExecuteWithCircuitBreakerAsync(command);
        }
 public async Task ExecuteWithCircuitBreakerAsync(ExecuteThroughCircuitBreakerCommand command) =>
 await _mediatr.Send(
     new ExecuteThroughCircuitBreakerCommand(command.Execution, _circuitBreaker)
     );