/// <summary> /// Initializes a new instance of the <see cref="ThrottlingMiddleware"/> class. /// Persists the policy object in cache using <see cref="IPolicyRepository"/> implementation. /// The policy object can be updated by <see cref="ThrottleManager"/> at runtime. /// </summary> /// <param name="policy"> /// The policy. /// </param> /// <param name="policyRepository"> /// The policy repository. /// </param> /// <param name="repository"> /// The repository. /// </param> /// <param name="logger"> /// The logger. /// </param> /// <param name="ipAddressParser"> /// The IpAddressParser /// </param> public ThrottlingMiddleware(OwinMiddleware next, ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser) : base(next) { core = new ThrottlingCore(); core.Repository = repository; Repository = repository; Logger = logger; if (ipAddressParser != null) { core.IpAddressParser = ipAddressParser; } QuotaExceededResponseCode = (HttpStatusCode)429; this.policy = policy; this.policyRepository = policyRepository; if (policyRepository != null) { policyRepository.Save(ThrottleManager.GetPolicyKey(), policy); } }
/// <summary> /// Initializes a new instance of the <see cref="ThrottlingHandler"/> class. /// Persists the policy object in cache using <see cref="IPolicyRepository"/> implementation. /// The policy object can be updated by <see cref="ThrottleManager"/> at runtime. /// </summary> /// <param name="policy"> /// The policy. /// </param> /// <param name="policyRepository"> /// The policy repository. /// </param> /// <param name="repository"> /// The repository. /// </param> /// <param name="logger"> /// The logger. /// </param> /// <param name="ipAddressParser"> /// The IpAddressParser /// </param> public ThrottlingHandler(ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser = null) { core = new ThrottlingCore { Repository = repository }; Repository = repository; Logger = logger; if (ipAddressParser != null) { core.IpAddressParser = ipAddressParser; } QuotaExceededResponseCode = (HttpStatusCode)429; this.Policy = policy; this.PolicyRepository = policyRepository; policyRepository?.Save(ThrottleManager.GetPolicyKey(), policy); }
/// <summary> /// Initializes a new instance of the <see cref="ThrottleProcesser"/> class. /// By default, the <see cref="QuotaExceededResponseCode"/> property /// is set to 429 (Too Many Requests). /// </summary> public ThrottleProcesser( ThrottlePolicy policy, IIpAddressParser ipAddressParser, IPolicyRepository policyRepo = null, IThrottleRepository throttleRepo = null) { Logger = new DefaultThrottleLogger(); QuotaExceededResponseCode = (HttpStatusCode)429; processResult = new ThrottleProcessResult { IsPass = true }; ThrottleRepo = throttleRepo; if (ThrottleRepo == null) { ThrottleRepo = new WebCacheThrottleRepository(); } ThrottlingCore = new ThrottlingCore(ipAddressParser); ThrottlingCore.ThrottleRepo = ThrottleRepo; PolicyRepo = policyRepo; if (PolicyRepo == null) { PolicyRepo = new WebCachePolicyRepository(); } Policy = policy; PolicyRepo.Save(ThrottleManager.GetPolicyKey(), policy); }
/// <summary> /// Initializes a new instance of the <see cref="ThrottlingMiddleware"/> class. /// Persists the policy object in cache using <see cref="IPolicyRepository"/> implementation. /// The policy object can be updated by <see cref="ThrottleManager"/> at runtime. /// </summary> /// <param name="policy"> /// The policy. /// </param> /// <param name="policyRepository"> /// The policy repository. /// </param> /// <param name="repository"> /// The repository. /// </param> /// <param name="logger"> /// The logger. /// </param> /// <param name="ipAddressParser"> /// The IpAddressParser /// </param> public ThrottlingMiddleware(OwinMiddleware next, ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser) : base(next) { core = new ThrottlingCore(); core.Repository = repository; Repository = repository; Logger = logger; if (ipAddressParser != null) { core.IpAddressParser = ipAddressParser; } QuotaExceededResponseCode = (HttpStatusCode)429; this.policy = policy; this.policyRepository = policyRepository; if (policyRepository != null) { policyRepository.Save(ThrottleManager.GetPolicyKey(), policy); } }
public ThrottlingFilter( ThrottlePolicy policy, IPolicyRepository policyRepo = null, IThrottleRepository throttleRepo = null) { var ipAddressParser = new ApiIpAddressParser(); processer = new ThrottleProcesser(policy, ipAddressParser, policyRepo, throttleRepo); }
/// <inheritdoc /> public IntersectThrottlingMiddleware( OwinMiddleware next, ThrottlePolicy policy, string header, string fallbackClientKey, IThrottleRepository throttleRepository ) : base(next, policy, null, throttleRepository ?? DefaultRepository, null, null) { mHeader = header ?? DefaultHeader; mFallbackClientKey = fallbackClientKey ?? DefaultFallbackClientKey; }
public ThrottlingMiddleware( OwinMiddleware next, ThrottlePolicy policy, IPolicyRepository policyRepo = null, IThrottleRepository throttleRepo = null) : base(next) { var ipAddressParser = new ApiIpAddressParser(); processer = new ThrottleProcesser(policy, ipAddressParser, policyRepo, throttleRepo); }
/// <summary> /// Initializes a new instance of the <see cref="ThrottlingFilter"/> class. /// Persists the policy object in cache using <see cref="IPolicyRepository"/> implementation. /// The policy object can be updated by <see cref="ThrottleManager"/> at runtime. /// </summary> /// <param name="policy"> /// The policy. /// </param> /// <param name="policyRepository"> /// The policy repository. /// </param> /// <param name="repository"> /// The repository. /// </param> /// <param name="logger"> /// The logger. /// </param> public ThrottlingFilter(ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger) { core = new ThrottlingCore(); core.Repository = repository; Repository = repository; Logger = logger; QuotaExceededResponseCode = (HttpStatusCode)429; this.policy = policy; this.policyRepository = policyRepository; if (policyRepository != null) { policyRepository.Save(ThrottleManager.GetPolicyKey(), policy); } }
/// <summary> /// Initializes a new instance of the <see cref="ThrottlingFilter"/> class. /// Persists the policy object in cache using <see cref="IPolicyRepository"/> implementation. /// The policy object can be updated by <see cref="ThrottleManager"/> at runtime. /// </summary> /// <param name="policy"> /// The policy. /// </param> /// <param name="policyRepository"> /// The policy repository. /// </param> /// <param name="repository"> /// The repository. /// </param> /// <param name="logger"> /// The logger. /// </param> public ThrottlingFilter(ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger) { core = new ThrottlingCore(); core.Repository = repository; Repository = repository; Logger = logger; QuotaExceededResponseCode = (HttpStatusCode)429; this.policy = policy; this.policyRepository = policyRepository; if (policyRepository != null) { policyRepository.Save(ThrottleManager.GetPolicyKey(), policy); } }
public HttpModuleThrottlingHandler(ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IIpAddressParser ipAddressParser = null) { core = new ThrottlingCore(); core.Repository = repository; Repository = repository; if (ipAddressParser != null) { core.IpAddressParser = ipAddressParser; } QuotaExceededResponseCode = (HttpStatusCode)429; this.policy = policy; this.policyRepository = policyRepository; if (policyRepository != null) { policyRepository.Save(ThrottleManager.GetPolicyKey(), policy); } }
public HttpThrottlePolicy(IThrottleRepository repository) : base(repository) { }
public ThrottlePolicy(IThrottleRepository repository) { Limiters = new List <Limiter>(); _repository = repository; }
public CustomThrottlingHandler(ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger, IIpAddressParser ipAddressParser = null) : base(policy, policyRepository, repository, logger, ipAddressParser) { }
public CustomThrottlingMiddleware(OwinMiddleware next, ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger) : base(next, policy, policyRepository, repository, logger) { }
public CustomThrottlingMiddleware(OwinMiddleware next, ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger) : base(next, policy, policyRepository, repository, logger) { }
public HttpThrottlePolicyBase(IThrottleRepository throttleRepository) : base(throttleRepository) { }
public CustomThrottlingFilter(ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger) : base(policy, policyRepository, repository, logger) { this.QuotaExceededMessage = "API calls quota exceeded! maximum admitted {0} per {1}."; }
public ThrottlePolicy(IThrottleRepository repository) { Limiters = new List<Limiter>(); _repository = repository; }
public CustomThrottlingFilter(ThrottlePolicy policy, IPolicyRepository policyRepository, IThrottleRepository repository, IThrottleLogger logger) : base(policy, policyRepository, repository, logger) { this.QuotaExceededMessage = "API calls quota exceeded! maximum admitted {0} per {1}."; }