Sha256: c05ea8aa6185a02bc05222cf6ea09a61399e7a959918532ab726249813ce1c92
Contents?: true
Size: 884 Bytes
Versions: 5
Compression:
Stored size: 884 Bytes
Contents
module ActiveHook module Server class Retry def initialize @done = false end def start until @done ActiveHook.redis.with do |conn| conn.watch('ah:retry') do retries = retrieve_retries(conn) update_retries(conn, retries) end end sleep 2 end end def shutdown @done = true end private def retrieve_retries(conn) conn.zrangebyscore('ah:retry', 0, Time.now.to_i) end def update_retries(conn, retries) if retries.any? conn.multi do |multi| multi.incrby('ah:total_retries', retries.count) multi.zrem('ah:retry', retries) multi.lpush('ah:queue', retries) end else conn.unwatch end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems