lib/prop/limiter.rb in prop-2.4.0 vs lib/prop/limiter.rb in prop-2.5.0

- old
+ new

@@ -140,11 +140,19 @@ end alias :configurations :handles private + def leaky_bucket_strategy?(strategy) + strategy == Prop::LeakyBucketStrategy + end + def _throttle(strategy, handle, key, cache_key, options) return [false, strategy.zero_counter] if disabled? + + if leaky_bucket_strategy?(strategy) + return Prop::LeakyBucketStrategy._throttle_leaky_bucket(handle, key, cache_key, options) + end counter = options.key?(:decrement) ? strategy.decrement(cache_key, options.fetch(:decrement), options) : strategy.increment(cache_key, options.fetch(:increment, 1), options)