Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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);
        }