Sha256: be8b75eee22120bb5acfa8e997ad43bb52b7678bb8d90a4b1e8d3d0af8b79390
Contents?: true
Size: 491 Bytes
Versions: 1
Compression:
Stored size: 491 Bytes
Contents
module GluttonRatelimit class BurstyRingBuffer < ParentLimiter def oldest_timestamp @timestamps = Array.new executions, (Time.now - @time_period) if @timestamps.nil? @timestamps[0] end def current_timestamp= new_stamp @timestamps.push(new_stamp).shift end def wait delta = Time.now - oldest_timestamp sleep(@time_period - delta) if delta < @time_period self.current_timestamp = Time.now end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
glutton_ratelimit-0.1.0 | lib/glutton_ratelimit/bursty_ring_buffer.rb |