Sha256: a67ca8b633f554c9eedd797622c4e9c5c5eea63bf568eaf18d3e7068b6944503
Contents?: true
Size: 863 Bytes
Versions: 1
Compression:
Stored size: 863 Bytes
Contents
module GluttonRatelimit def rate_limit symbol, executions, time_period, rl_class = AveragedThrottle rl = rl_class.new executions, time_period old_symbol = "#{symbol}_old".to_sym alias_method old_symbol, symbol define_method symbol do |*args| rl.wait self.send old_symbol, *args end end private # All the other classes extend this parent and are therefore # constructed in the same manner. class ParentLimiter attr_reader :executions def initialize executions, time_period @executions = executions @time_period = time_period end end end dir = File.expand_path(File.dirname(__FILE__)) require File.join(dir, "glutton_ratelimit", "bursty_ring_buffer") require File.join(dir, "glutton_ratelimit", "bursty_token_bucket") require File.join(dir, "glutton_ratelimit", "averaged_throttle")
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glutton_ratelimit-0.1.0 | lib/glutton_ratelimit.rb |