Sha256: 4ebb11c538ac82641308d61830a3f3be9d53c8de3d333776b7d1512cb78ba082
Contents?: true
Size: 975 Bytes
Versions: 2
Compression:
Stored size: 975 Bytes
Contents
module ActiveHook module Server class Retry def initialize @done = false end def start until @done retries = retrieve_retries update(retries) unless retries.empty? sleep 2 end end def shutdown @done = true end private def retrieve_retries ActiveHook.redis.with do |conn| conn.zrangebyscore('ah:retry', 0, Time.now.to_i) end end def update(retries) ActiveHook.redis.with do |conn| conn.pipelined do conn.zrem('ah:retry', retries) conn.incrby('ah:total_retries', retries.count) end end retries.each { |r| RetryRunner.new(r) } end end class RetryRunner def initialize(json) @json = json @hook = Hook.new(JSON.parse(@json)) start end def start @hook.perform end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activehook-0.1.4 | lib/activehook/server/retry.rb |
activehook-0.1.3 | lib/activehook/server/retry.rb |