Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public static string GetPerUserPerRateLimitConfigCacheKey(string userId, RateLimitConfigOptions config) => $"user:{userId}{GetRateLimitConfigUniqueKey(config)}";
Esempio n. 3
0
 public static string GetRateLimitConfigUniqueKey(RateLimitConfigOptions config) => GetRateLimitConfigUniqueKey(config.HttpMethod, config.EndsWithPath);