public WebSocketsProxyMiddleware(OcelotRequestDelegate next,
                                  IOcelotLoggerFactory loggerFactory)
     : base(loggerFactory.CreateLogger <WebSocketsProxyMiddleware>())
 {
     ;
     _next = next;
 }
 public FileInternalConfigurationCreator(
     IConfigurationValidator configurationValidator,
     IOcelotLoggerFactory loggerFactory,
     IClaimsToThingCreator claimsToThingCreator,
     IAuthenticationOptionsCreator authOptionsCreator,
     IUpstreamTemplatePatternCreator upstreamTemplatePatternCreator,
     IRequestIdKeyCreator requestIdKeyCreator,
     IServiceProviderConfigurationCreator serviceProviderConfigCreator,
     IQoSOptionsCreator qosOptionsCreator,
     IReRouteOptionsCreator fileReRouteOptionsCreator,
     IRateLimitOptionsCreator rateLimitOptionsCreator,
     IRegionCreator regionCreator,
     IHttpHandlerOptionsCreator httpHandlerOptionsCreator,
     IAdministrationPath adminPath,
     IHeaderFindAndReplaceCreator headerFAndRCreator,
     IDownstreamAddressesCreator downstreamAddressesCreator
     )
 {
     _downstreamAddressesCreator = downstreamAddressesCreator;
     _headerFAndRCreator         = headerFAndRCreator;
     _adminPath                      = adminPath;
     _regionCreator                  = regionCreator;
     _rateLimitOptionsCreator        = rateLimitOptionsCreator;
     _requestIdKeyCreator            = requestIdKeyCreator;
     _upstreamTemplatePatternCreator = upstreamTemplatePatternCreator;
     _authOptionsCreator             = authOptionsCreator;
     _configurationValidator         = configurationValidator;
     _logger = loggerFactory.CreateLogger <FileInternalConfigurationCreator>();
     _claimsToThingCreator         = claimsToThingCreator;
     _serviceProviderConfigCreator = serviceProviderConfigCreator;
     _qosOptionsCreator            = qosOptionsCreator;
     _fileReRouteOptionsCreator    = fileReRouteOptionsCreator;
     _httpHandlerOptionsCreator    = httpHandlerOptionsCreator;
 }
        public ConsulFileConfigurationRepository(
            Cache.IOcelotCache <FileConfiguration> cache,
            IInternalConfigurationRepository repo,
            IConsulClientFactory factory,
            IOcelotLoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <ConsulFileConfigurationRepository>();
            _cache  = cache;

            var internalConfig = repo.Get();

            _configurationKey = "InternalConfiguration";

            string token = null;

            if (!internalConfig.IsError)
            {
                token             = internalConfig.Data.ServiceProviderConfiguration.Token;
                _configurationKey = !string.IsNullOrEmpty(internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey) ?
                                    internalConfig.Data.ServiceProviderConfiguration.ConfigurationKey : _configurationKey;
            }

            var config = new ConsulRegistryConfiguration(internalConfig.Data.ServiceProviderConfiguration.Host,
                                                         internalConfig.Data.ServiceProviderConfiguration.Port, _configurationKey, token);

            _consul = factory.Get(config);
        }
Ejemplo n.º 4
0
        public ConsulFileConfigurationRepository(
            Cache.IOcelotCache <FileConfiguration> cache,
            IInternalConfigurationRepository repo,
            IConsulClientFactory factory,
            IOcelotLoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <ConsulFileConfigurationRepository>();
            _cache  = cache;

            var internalConfig = repo.Get();

            var    consulHost = "localhost";
            var    consulPort = 8500;
            string token      = null;

            if (!internalConfig.IsError)
            {
                consulHost = string.IsNullOrEmpty(internalConfig.Data.ServiceProviderConfiguration?.Host) ? consulHost : internalConfig.Data.ServiceProviderConfiguration?.Host;
                consulPort = internalConfig.Data.ServiceProviderConfiguration?.Port ?? consulPort;
                token      = internalConfig.Data.ServiceProviderConfiguration?.Token;
            }

            var config = new ConsulRegistryConfiguration(consulHost, consulPort, OcelotConfiguration, token);

            _consul = factory.Get(config);
        }
Ejemplo n.º 5
0
 public FileOcelotConfigurationCreator(
     IOptions <FileConfiguration> options,
     IConfigurationValidator configurationValidator,
     IOcelotLoggerFactory loggerFactory,
     ILoadBalancerFactory loadBalancerFactory,
     ILoadBalancerHouse loadBalancerHouse,
     IQoSProviderFactory qoSProviderFactory,
     IQosProviderHouse qosProviderHouse,
     IClaimsToThingCreator claimsToThingCreator,
     IAuthenticationOptionsCreator authOptionsCreator,
     IUpstreamTemplatePatternCreator upstreamTemplatePatternCreator,
     IRequestIdKeyCreator requestIdKeyCreator,
     IServiceProviderConfigurationCreator serviceProviderConfigCreator,
     IQoSOptionsCreator qosOptionsCreator,
     IReRouteOptionsCreator fileReRouteOptionsCreator,
     IRateLimitOptionsCreator rateLimitOptionsCreator
     )
 {
     _rateLimitOptionsCreator        = rateLimitOptionsCreator;
     _requestIdKeyCreator            = requestIdKeyCreator;
     _upstreamTemplatePatternCreator = upstreamTemplatePatternCreator;
     _authOptionsCreator             = authOptionsCreator;
     _loadBalanceFactory             = loadBalancerFactory;
     _loadBalancerHouse      = loadBalancerHouse;
     _qoSProviderFactory     = qoSProviderFactory;
     _qosProviderHouse       = qosProviderHouse;
     _options                = options;
     _configurationValidator = configurationValidator;
     _logger = loggerFactory.CreateLogger <FileOcelotConfigurationCreator>();
     _claimsToThingCreator         = claimsToThingCreator;
     _serviceProviderConfigCreator = serviceProviderConfigCreator;
     _qosOptionsCreator            = qosOptionsCreator;
     _fileReRouteOptionsCreator    = fileReRouteOptionsCreator;
 }
Ejemplo n.º 6
0
        public PollyQoSProvider(ReRoute reRoute, IOcelotLoggerFactory loggerFactory)
        {
            _logger = loggerFactory.CreateLogger <PollyQoSProvider>();

            _timeoutPolicy = Policy.TimeoutAsync(TimeSpan.FromMilliseconds(reRoute.QosOptionsOptions.TimeoutValue), reRoute.QosOptionsOptions.TimeoutStrategy);

            _circuitBreakerPolicy = Policy
                                    .Handle <HttpRequestException>()
                                    .Or <TimeoutRejectedException>()
                                    .Or <TimeoutException>()
                                    .CircuitBreakerAsync(
                exceptionsAllowedBeforeBreaking: reRoute.QosOptionsOptions.ExceptionsAllowedBeforeBreaking,
                durationOfBreak: TimeSpan.FromMilliseconds(reRoute.QosOptionsOptions.DurationOfBreak),
                onBreak: (ex, breakDelay) =>
            {
                _logger.LogError(
                    ".Breaker logging: Breaking the circuit for " + breakDelay.TotalMilliseconds + "ms!", ex);
            },
                onReset: () =>
            {
                _logger.LogDebug(".Breaker logging: Call ok! Closed the circuit again.");
            },
                onHalfOpen: () =>
            {
                _logger.LogDebug(".Breaker logging: Half-open; next call is a trial.");
            }
                );

            _circuitBreaker = new CircuitBreaker(_circuitBreakerPolicy, _timeoutPolicy);
        }
Ejemplo n.º 7
0
 public Etcd(EtcdRegistryConfiguration config, IOcelotLoggerFactory factory, IEtcdClientFactory clientFactory)
 {
     logger                 = factory.CreateLogger <Etcd>();
     this.config            = config;
     this.etcdClientFactory = clientFactory;
     Services               = new List <Service>();
 }
Ejemplo n.º 8
0
 public CzarRpcMiddleware(OcelotRequestDelegate next, IRpcClientFactory clientFactory,
                          IOcelotLoggerFactory loggerFactory, ICzarRpcProcessor czarRpcProcessor) : base(loggerFactory.CreateLogger <CzarRpcMiddleware>())
 {
     _next             = next;
     _clientFactory    = clientFactory;
     _czarRpcProcessor = czarRpcProcessor;
 }
 public DynamicGrainMethodInvoker(IParameterBinder parameterBinder, IOcelotLoggerFactory factory,
                                  JsonSerializer jsonSerializer)
 {
     this._parameterBinder = parameterBinder;
     this._logger          = factory.CreateLogger <DynamicGrainMethodInvoker>();
     this._jsonSerializer  = jsonSerializer;
 }
 public FileOcelotConfigurationCreator(
     IOptions <FileConfiguration> options,
     IConfigurationValidator configurationValidator,
     IOcelotLoggerFactory loggerFactory,
     IClaimsToThingCreator claimsToThingCreator,
     IAuthenticationOptionsCreator authOptionsCreator,
     IUpstreamTemplatePatternCreator upstreamTemplatePatternCreator,
     IRequestIdKeyCreator requestIdKeyCreator,
     IServiceProviderConfigurationCreator serviceProviderConfigCreator,
     IQoSOptionsCreator qosOptionsCreator,
     IReRouteOptionsCreator fileReRouteOptionsCreator,
     IRateLimitOptionsCreator rateLimitOptionsCreator,
     IRegionCreator regionCreator,
     IHttpHandlerOptionsCreator httpHandlerOptionsCreator,
     IAdministrationPath adminPath
     )
 {
     _adminPath                      = adminPath;
     _regionCreator                  = regionCreator;
     _rateLimitOptionsCreator        = rateLimitOptionsCreator;
     _requestIdKeyCreator            = requestIdKeyCreator;
     _upstreamTemplatePatternCreator = upstreamTemplatePatternCreator;
     _authOptionsCreator             = authOptionsCreator;
     _options = options;
     _configurationValidator = configurationValidator;
     _logger = loggerFactory.CreateLogger <FileOcelotConfigurationCreator>();
     _claimsToThingCreator         = claimsToThingCreator;
     _serviceProviderConfigCreator = serviceProviderConfigCreator;
     _qosOptionsCreator            = qosOptionsCreator;
     _fileReRouteOptionsCreator    = fileReRouteOptionsCreator;
     _httpHandlerOptionsCreator    = httpHandlerOptionsCreator;
 }
 public PollyCircuitBreakingDelegatingHandler(
     PollyQoSProvider qoSProvider,
     IOcelotLoggerFactory loggerFactory)
 {
     _qoSProvider = qoSProvider;
     _logger      = loggerFactory.CreateLogger <PollyCircuitBreakingDelegatingHandler>();
 }
Ejemplo n.º 12
0
 public LoadBalancingMiddleware(OcelotRequestDelegate next,
                                IOcelotLoggerFactory loggerFactory,
                                ILoadBalancerHouse loadBalancerHouse)
 {
     _next              = next;
     _logger            = loggerFactory.CreateLogger <LoadBalancingMiddleware>();
     _loadBalancerHouse = loadBalancerHouse;
 }
 public DownstreamRequestInitialiserMiddleware(OcelotRequestDelegate next,
                                               IOcelotLoggerFactory loggerFactory,
                                               Mapper.IRequestMapper requestMapper)
     : base(loggerFactory.CreateLogger <DownstreamRequestInitialiserMiddleware>())
 {
     _next          = next;
     _requestMapper = requestMapper;
 }
        public ConsulServiceDiscoveryProvider(ConsulRegistryConfiguration config, IOcelotLoggerFactory factory, IConsulClientFactory clientFactory)
        {
            ;
            _logger = factory.CreateLogger <ConsulServiceDiscoveryProvider>();

            _config = config;
            _consul = clientFactory.Get(_config);
        }
Ejemplo n.º 15
0
 public ExceptionHandlerMiddleware(RequestDelegate next,
                                   IOcelotLoggerFactory loggerFactory,
                                   IRequestScopedDataRepository repo)
     : base(loggerFactory.CreateLogger <ExceptionHandlerMiddleware>())
 {
     _next = next;
     _repo = repo;
 }
Ejemplo n.º 16
0
 public ReRouteRequestIdMiddleware(OcelotRequestDelegate next,
                                   IOcelotLoggerFactory loggerFactory,
                                   IRequestScopedDataRepository requestScopedDataRepository)
     : base(loggerFactory.CreateLogger <ReRouteRequestIdMiddleware>())
 {
     _next = next;
     _requestScopedDataRepository = requestScopedDataRepository;
 }
Ejemplo n.º 17
0
 public ServiceDiscoveryProviderFactory(IOcelotLoggerFactory factory, IServiceProvider provider)
 {
     _factory   = factory;
     _provider  = provider;
     _delegates = provider
                  .GetServices <ServiceDiscoveryFinderDelegate>()
                  .ToList();
 }
Ejemplo n.º 18
0
 public HttpClientHttpRequester(IOcelotLoggerFactory loggerFactory,
                                IHttpClientCache cacheHandlers,
                                IDelegatingHandlerHandlerFactory house)
 {
     _logger        = loggerFactory.CreateLogger <HttpClientHttpRequester>();
     _cacheHandlers = cacheHandlers;
     _factory       = house;
 }
 public ClaimsToDownstreamPathMiddleware(OcelotRequestDelegate next,
                                         IOcelotLoggerFactory loggerFactory,
                                         IChangeDownstreamPathTemplate changeDownstreamPathTemplate)
     : base(loggerFactory.CreateLogger <ClaimsToDownstreamPathMiddleware>())
 {
     _next = next;
     _changeDownstreamPathTemplate = changeDownstreamPathTemplate;
 }
 public ClaimsToQueryStringMiddleware(RequestDelegate next,
                                      IOcelotLoggerFactory loggerFactory,
                                      IAddQueriesToRequest addQueriesToRequest)
     : base(loggerFactory.CreateLogger <ClaimsToQueryStringMiddleware>())
 {
     _next = next;
     _addQueriesToRequest = addQueriesToRequest;
 }
 public DownstreamUrlCreatorMiddleware(OcelotRequestDelegate next,
                                       IOcelotLoggerFactory loggerFactory,
                                       IDownstreamPathPlaceholderReplacer replacer)
 {
     _next     = next;
     _replacer = replacer;
     _logger   = loggerFactory.CreateLogger <DownstreamUrlCreatorMiddleware>();
 }
 public OutputCacheMiddleware(OcelotRequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IOcelotCache <CachedResponse> outputCache)
     : base(loggerFactory.CreateLogger <OutputCacheMiddleware>())
 {
     _next        = next;
     _outputCache = outputCache;
 }
 public HttpRequestHeadersBuilderMiddleware(OcelotRequestDelegate next,
                                            IOcelotLoggerFactory loggerFactory,
                                            IAddHeadersToRequest addHeadersToRequest)
 {
     _next = next;
     _addHeadersToRequest = addHeadersToRequest;
     _logger = loggerFactory.CreateLogger <HttpRequestHeadersBuilderMiddleware>();
 }
 public DefaultRouteValuesBuilder(IOptions <OrleansHttpGatewayOptions> options
                                  , IOptions <OrleansRequesterConfiguration> config
                                  , IOcelotLoggerFactory factory)
 {
     this._config  = config?.Value;
     this._options = options.Value;
     this._logger  = factory.CreateLogger <DefaultRouteValuesBuilder>();
 }
Ejemplo n.º 25
0
 public ClaimsToClaimsMiddleware(OcelotRequestDelegate next,
                                 IOcelotLoggerFactory loggerFactory,
                                 IAddClaimsToRequest addClaimsToRequest)
     : base(loggerFactory.CreateLogger <ClaimsToClaimsMiddleware>())
 {
     _next = next;
     _addClaimsToRequest = addClaimsToRequest;
 }
Ejemplo n.º 26
0
 public QueryStringBuilderMiddleware(OcelotRequestDelegate next,
                                     IOcelotLoggerFactory loggerFactory,
                                     IAddQueriesToRequest addQueriesToRequest)
     : base(loggerFactory.CreateLogger <QueryStringBuilderMiddleware>())
 {
     _next = next;
     _addQueriesToRequest = addQueriesToRequest;
 }
Ejemplo n.º 27
0
 public HttpRequesterMiddleware(OcelotRequestDelegate next,
                                IOcelotLoggerFactory loggerFactory,
                                IHttpRequester requester)
 {
     _next      = next;
     _requester = requester;
     _logger    = loggerFactory.CreateLogger <HttpRequesterMiddleware>();
 }
 public CzarHttpRequesterMiddleware(OcelotRequestDelegate next,
                                    IOcelotLoggerFactory loggerFactory,
                                    IHttpRequester requester)
     : base(loggerFactory.CreateLogger <CzarHttpRequesterMiddleware>())
 {
     _next      = next;
     _requester = requester;
 }
Ejemplo n.º 29
0
 public ClaimsBuilderMiddleware(OcelotRequestDelegate next,
                                IOcelotLoggerFactory loggerFactory,
                                IAddClaimsToRequest addClaimsToRequest)
 {
     _next = next;
     _addClaimsToRequest = addClaimsToRequest;
     _logger             = loggerFactory.CreateLogger <ClaimsBuilderMiddleware>();
 }
Ejemplo n.º 30
0
 public ClientRateLimitMiddleware(RequestDelegate next,
                                  IOcelotLoggerFactory loggerFactory,
                                  IRateLimitCounterHandler counterHandler)
     : base(loggerFactory.CreateLogger <ClientRateLimitMiddleware>())
 {
     _next      = next;
     _processor = new ClientRateLimitProcessor(counterHandler);
 }