Exemplo n.º 1
0
        private void ThenTheDelegatesAreAddedCorrectly()
        {
            var delegates = _provider.Get();
            var del       = delegates[0].Invoke();
            var handler   = (FakeDelegatingHandler)del;

            handler.Order.ShouldBe(0);

            del     = delegates[1].Invoke();
            handler = (FakeDelegatingHandler)del;
            handler.Order.ShouldBe(1);
        }
Exemplo n.º 2
0
        public Response <IDelegatingHandlerHandlerProvider> Get(DownstreamReRoute request)
        {
            var handlersAppliedToAll = _allRoutesProvider.Get();

            var provider = new DelegatingHandlerHandlerProvider();

            foreach (var handler in handlersAppliedToAll)
            {
                provider.Add(handler);
            }

            if (request.HttpHandlerOptions.UseTracing)
            {
                provider.Add(() => (DelegatingHandler)_factory.Get());
            }

            if (request.IsQos)
            {
                var qosProvider = _qosProviderHouse.Get(request);

                if (qosProvider.IsError)
                {
                    return(new ErrorResponse <IDelegatingHandlerHandlerProvider>(qosProvider.Errors));
                }

                provider.Add(() => new PollyCircuitBreakingDelegatingHandler(qosProvider.Data, _loggerFactory));
            }

            return(new OkResponse <IDelegatingHandlerHandlerProvider>(provider));
        }
Exemplo n.º 3
0
        public IDelegatingHandlerHandlerProvider Get(Request.Request request)
        {
            var handlersAppliedToAll = _allRoutesProvider.Get();

            var provider = new DelegatingHandlerHandlerProvider();

            foreach (var handler in handlersAppliedToAll)
            {
                provider.Add(handler);
            }

            if (request.IsTracing)
            {
                provider.Add(() => (DelegatingHandler)_tracingHandler);
            }

            if (request.IsQos)
            {
                provider.Add(() => new PollyCircuitBreakingDelegatingHandler(request.QosProvider, _loggerFactory));
            }

            return(provider);
        }