Exemplo n.º 1
0
        protected override async Task <IExecutionResult> ExecuteInternal(BreakerExecutionContext executionContext)
        {
            await this._lock.WaitAsync();

            try
            {
                var t = executionContext.Action();

                t.Wait();
                this._successCount++;
                if (this._successCount > 0)
                {
                    this.StateManager.Close();
                }
                return(new SuccessExecutionResult(base.GetResultFactory(t)));
            }
            catch (Exception e)
            {
                return(await this.Trip(e, executionContext));
            }
            finally
            {
                this._lock.Release();
            }
        }
Exemplo n.º 2
0
        protected override Task <IExecutionResult> ExecuteInternal(BreakerExecutionContext executionContext)
        {
            var t = executionContext.Action();

            t.Wait();

            return(Task.FromResult <IExecutionResult>(new SuccessExecutionResult(base.GetResultFactory(t))));
        }
Exemplo n.º 3
0
 protected override Task <IExecutionResult> Trip(Exception e, BreakerExecutionContext executionContext)
 {
     Interlocked.Increment(ref this._failCount);
     if (_failCount > 1)
     {
         this.StateManager.Open();
     }
     return(Task.FromResult <IExecutionResult>(new FailedExecutionResult(() => null, this.StateManager.CurrentState.State, e)));
 }
Exemplo n.º 4
0
        public async Task BreakerTest1()
        {
            //ARRANGE
            var validator = new BackchannelCertificateValidatorMock(() => true);
            var webClient = new HttpDocumentRetrieverMock(validator);
            var manager   = new StateManager(new TimeManager(), new StateProviderMock());

            BreakerProxy.StateProviderFactory(() => manager);
            var breaker = BreakerProxy.Instance;

            var executingContext = new BreakerExecutionContext {
                Action = () => webClient.GetDocumentAsync("https://dg-mfb/idp/shibboleth", CancellationToken.None)
            };
            //ACT
            var response = await breaker.Execute(executingContext);

            //ASSERT
        }
Exemplo n.º 5
0
 protected override Task <IExecutionResult> Trip(Exception e, BreakerExecutionContext executionContext)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 6
0
 protected override Task <IExecutionResult> ExecuteInternal(BreakerExecutionContext executionContext)
 {
     return(Task.FromResult <IExecutionResult>(new FailedExecutionResult(() => null, State.Open, null)));
 }
Exemplo n.º 7
0
 protected override Task <IExecutionResult> ExecuteInternal(BreakerExecutionContext executionContext)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 8
0
        public async Task <IBrakerResponse> Execute(BreakerExecutionContext executionContext)
        {
            var result = await this._stateManager.Execute(executionContext);

            return(result.Execute());
        }
Exemplo n.º 9
0
 protected override Task <IExecutionResult> Trip(Exception e, BreakerExecutionContext executionContext)
 {
     this.StateManager.Open();
     return(Task.FromResult <IExecutionResult>(new FailedExecutionResult(() => null, this.StateManager.CurrentState.State, e)));
 }
Exemplo n.º 10
0
 public Task <IExecutionResult> Execute(BreakerExecutionContext executionContext)
 {
     return(this.CurrentState.Execute(executionContext));
 }