public OutputCacheMiddlewareRealCacheTests()
        {
            _loggerFactory = new Mock <IOcelotLoggerFactory>();
            _logger        = new Mock <IOcelotLogger>();
            _loggerFactory.Setup(x => x.CreateLogger <OutputCacheMiddleware>()).Returns(_logger.Object);

            _mockOptions       = new Mock <IOptions <OcelotEasyCachingOptions> >();
            _cacheKeyGenerator = new CacheKeyGenerator();
            _mockOptions.Setup(x => x.Value).Returns(new OcelotEasyCachingOptions()
            {
                EnableHybrid = false,
                ProviderName = "m1",
            });

            IServiceCollection services = new ServiceCollection();

            services.AddEasyCaching(x => x.UseInMemory(options => options.MaxRdSecond = 0, "m1"));
            IServiceProvider serviceProvider = services.BuildServiceProvider();
            var factory = serviceProvider.GetService <IEasyCachingProviderFactory>();

            _ocelotCache       = new OcelotEasyCachingCache <CachedResponse>(_mockOptions.Object, factory, null);
            _downstreamContext = new DownstreamContext(new DefaultHttpContext());
            _downstreamContext.DownstreamRequest = new Request.Middleware.DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"));
            _next       = context => Task.CompletedTask;
            _middleware = new OutputCacheMiddleware(_next, _loggerFactory.Object, _ocelotCache, _cacheKeyGenerator);
        }
Beispiel #2
0
 public RedisInternalConfigurationRepository(CusOcelotConfiguration options, IFileConfigurationRepository fileConfigurationRepository, IInternalConfigurationCreator internalConfigurationCreator, IOcelotCache <InternalConfiguration> ocelotCache)
 {
     _fileConfigurationRepository  = fileConfigurationRepository;
     _internalConfigurationCreator = internalConfigurationCreator;
     _options     = options;
     _ocelotCache = ocelotCache;
 }
Beispiel #3
0
 public AbpEfCoreFileConfigurationRepository(ConfigCacheOptions option, IOcelotCache <FileConfiguration> cache, IOcelotRepository ocelotGlobalConfigurationRepository, IOcelotLoggerFactory loggerFactory)
 {
     _ocelotGlobalConfigurationRepository = ocelotGlobalConfigurationRepository;
     _option = option;
     _cache  = cache;
     _logger = loggerFactory.CreateLogger <AbpEfCoreFileConfigurationRepository>();
 }
 public CacheHelper(IOcelotCache <CachedResponse> outputCache,
                    ICacheKeyGenerator cacheGenerator,
                    ILogger <CacheHelper> logger)
 {
     _outputCache    = outputCache;
     _cacheGenerator = cacheGenerator;
     _logger         = logger;
 }
 public CusAuthenticationProcessor(IClientAuthenticationRepository clientAuthenticationRepository,
                                   CusOcelotConfiguration options,
                                   IOcelotCache <ClientRoleModel> ocelotCache)
 {
     _clientAuthenticationRepository = clientAuthenticationRepository;
     _options     = options;
     _ocelotCache = ocelotCache;
 }
 public OutputCacheMiddleware(OcelotRequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IOcelotCache <CachedResponse> outputCache)
     : base(loggerFactory.CreateLogger <OutputCacheMiddleware>())
 {
     _next        = next;
     _outputCache = outputCache;
 }
 public CzarClientRateLimitProcessor(CzarOcelotConfiguration options, IClientRateLimitRepository clientRateLimitRepository, IOcelotCache <CzarClientRateLimitCounter?> clientRateLimitCounter, IOcelotCache <ClientRoleModel> ocelotCache, IOcelotCache <RateLimitRuleModel> rateLimitRuleCache)
 {
     _options = options;
     _clientRateLimitRepository = clientRateLimitRepository;
     _clientRateLimitCounter    = clientRateLimitCounter;
     _ocelotCache        = ocelotCache;
     _rateLimitRuleCache = rateLimitRuleCache;
 }
Beispiel #8
0
 public OutputCacheMiddleware(OcelotRequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IOcelotCache <CachedResponse> outputCache,
                              ICacheKeyGenerator cacheGeneratot)
     : base(loggerFactory.CreateLogger <OutputCacheMiddleware>())
 {
     _next           = next;
     _outputCache    = outputCache;
     _cacheGeneratot = cacheGeneratot;
 }
Beispiel #9
0
 public OutputCacheMiddleware(RequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IRequestScopedDataRepository scopedDataRepository,
                              IOcelotCache <HttpResponseMessage> outputCache)
     : base(scopedDataRepository)
 {
     _next        = next;
     _outputCache = outputCache;
     _logger      = loggerFactory.CreateLogger <OutputCacheMiddleware>();
 }
Beispiel #10
0
 public OutputCacheMiddleware(OcelotRequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IOcelotCache <CachedResponse> outputCache,
                              IRegionCreator regionCreator)
 {
     _next          = next;
     _outputCache   = outputCache;
     _logger        = loggerFactory.CreateLogger <OutputCacheMiddleware>();
     _regionCreator = regionCreator;
 }
 public FileConfigurationRepository(
     ConfigCacheOptions option,
     IOcelotCache <FileConfiguration> cache,
     IAbpFileConfigurationRepository abpFileConfigurationRepository,
     IOcelotLoggerFactory loggerFactory)
 {
     _option = option;
     _cache  = cache;
     _abpFileConfigurationRepository = abpFileConfigurationRepository;
     _logger = loggerFactory.CreateLogger <FileConfigurationRepository>();
 }
 public OutputCacheMiddleware(RequestDelegate next,
                              IOcelotLoggerFactory loggerFactory,
                              IRequestScopedDataRepository scopedDataRepository,
                              IOcelotCache <CachedResponse> outputCache,
                              IRegionCreator regionCreator)
     : base(scopedDataRepository)
 {
     _next          = next;
     _outputCache   = outputCache;
     _logger        = loggerFactory.CreateLogger <OutputCacheMiddleware>();
     _regionCreator = regionCreator;
 }
 public AhphClientRateLimitProcessor(
     AhphOcelotConfiguration option,
     IClientRateLimitRepository clientRateLimitRepository,
     IOcelotCache <AhphClientRateLimitCounter?> clientRateLimitCounter,
     IOcelotCache <ClientRoleModel> ocelotCache,
     IOcelotCache <RateLimitRuleModel> rateLimitRuleCache)
 {
     _option = option;
     _clientRateLimitRepository = clientRateLimitRepository;
     _clientRateLimitCounter    = clientRateLimitCounter;
     _ocelotCache        = ocelotCache;
     _rateLimitRuleCache = rateLimitRuleCache;
 }
Beispiel #14
0
        public FileConfigurationRepository_Tests()
        {
            _cachOptions      = Substitute.For <IOcelotCache <FileConfiguration> >();
            _ocelotRepository = GetRequiredService <IOcelotRepository>();
            _loggerFactory    = Substitute.For <IOcelotLoggerFactory>();
            var logger = Substitute.For <IOcelotLogger>();

            _loggerFactory.CreateLogger <FileConfigurationRepository>().Returns(logger);


            _configCacheOptions = new ConfigCacheOptions {
                GatewayName = "middleware"
            };
        }
        public OutputCacheMiddlewareRealCacheTests()
        {
            _loggerFactory = new Mock <IOcelotLoggerFactory>();
            _logger        = new Mock <IOcelotLogger>();
            _loggerFactory.Setup(x => x.CreateLogger <OutputCacheMiddleware>()).Returns(_logger.Object);
            var cacheManagerOutputCache = CacheFactory.Build <CachedResponse>("OcelotOutputCache", x =>
            {
                x.WithDictionaryHandle();
            });

            _cacheManager      = new OcelotCacheManagerCache <CachedResponse>(cacheManagerOutputCache);
            _downstreamContext = new DownstreamContext(new DefaultHttpContext());
            _downstreamContext.DownstreamRequest = new Ocelot.Request.Middleware.DownstreamRequest(new HttpRequestMessage(HttpMethod.Get, "https://some.url/blah?abcd=123"));
            _next       = context => Task.CompletedTask;
            _middleware = new OutputCacheMiddleware(_next, _loggerFactory.Object, _cacheManager);
        }
Beispiel #16
0
        protected override void GivenTheTestServerServicesAreConfigured(IServiceCollection services)
        {
            var cacheManagerOutputCache = CacheFactory.Build <CachedResponse>("OcelotOutputCache", x =>
            {
                x.WithDictionaryHandle();
            });

            _cacheManager = new OcelotCacheManagerCache <CachedResponse>(cacheManagerOutputCache);

            services.AddSingleton <ICacheManager <CachedResponse> >(cacheManagerOutputCache);
            services.AddSingleton <IOcelotCache <CachedResponse> >(_cacheManager);

            services.AddSingleton <IOcelotLoggerFactory, AspDotNetLoggerFactory>();

            services.AddLogging();
            services.AddSingleton(_cacheManager);
            services.AddSingleton(ScopedRepository.Object);
            services.AddSingleton <IRegionCreator, RegionCreator>();
        }
Beispiel #17
0
 /// <summary>
 /// 构造注入
 /// </summary>
 /// <param name="cache"></param>
 public RedisConfigurationRepository(IOcelotCache <FileConfiguration> cache, IOptions <CacheOptions> _options)
 {
     _cache  = cache;
     options = _options;
 }
 public MySqlFileConfigurationRepository(IOcelotCache <FileConfiguration> cache, ConfigAuthLimitCacheOptions option, IHostingEnvironment hostingEnvironment)
 {
     _cache              = cache;
     _option             = option;
     _hostingEnvironment = hostingEnvironment;
 }
Beispiel #19
0
 public OutputCacheController(IOcelotCache <CachedResponse> cache)
 {
     _cache = cache;
 }
Beispiel #20
0
 public CzarRpcProcessor(IRpcRepository rpcRepository, CzarOcelotConfiguration options, IOcelotCache <RemoteInvokeMessage> ocelotCache)
 {
     _rpcRepository = rpcRepository;
     _options       = options;
     _ocelotCache   = ocelotCache;
 }
Beispiel #21
0
 public SqlServerFileConfigurationRepository(ConfigAuthLimitCacheOptions option, IOcelotCache <FileConfiguration> cache, IOcelotLoggerFactory loggerFactory)
 {
     _option = option;
     _cache  = cache;
     _logger = loggerFactory.CreateLogger <SqlServerFileConfigurationRepository>();
 }
Beispiel #22
0
 /// <summary>
 /// 构造注入
 /// </summary>
 /// <param name="cache"></param>
 public EFConfigurationRepository(IOcelotCache <FileConfiguration> cache, IOptions <CacheOptions> _options, IServiceProvider _serviceProvider)
 {
     _cache          = cache;
     options         = _options;
     serviceProvider = _serviceProvider;
 }
Beispiel #23
0
 public OutputCacheController(IOcelotCache <HttpResponseMessage> cache)
 {
     _cache = cache;
 }