public IRequestThrottler GetRequestThrottler(RateLimitConfigOptions config) { if (config is null) { throw new System.ArgumentNullException(nameof(config)); } IRequestThrottler perSecThrottler = null; if (config.PerSecLimit > 0) { Console.WriteLine(">>>>>> initializing per sec throttler as well"); perSecThrottler = new PerSecRequestThrottler(null, _redisCacheManager); } if (config.PerMinLimit > 0) { return(new PerMinRequestThrottler(perSecThrottler, _redisCacheManager)); } return(null); }
public static string GetPerUserPerRateLimitConfigCacheKey(string userId, RateLimitConfigOptions config) => $"user:{userId}{GetRateLimitConfigUniqueKey(config)}";
public static string GetRateLimitConfigUniqueKey(RateLimitConfigOptions config) => GetRateLimitConfigUniqueKey(config.HttpMethod, config.EndsWithPath);