lib/activehook/server/retry.rb in activehook-server-0.1.5 vs lib/activehook/server/retry.rb in activehook-server-0.1.6
- old
+ new
@@ -5,12 +5,12 @@
@done = false
end
def start
until @done
- ActiveHook::Server.redis.with do |conn|
- conn.watch('ah:retry') do
+ Server.redis.with do |conn|
+ conn.watch(Server.config.retry_namespace) do
retries = retrieve_retries(conn)
update_retries(conn, retries)
end
end
sleep 2
@@ -22,18 +22,18 @@
end
private
def retrieve_retries(conn)
- conn.zrangebyscore('ah:retry', 0, Time.now.to_i)
+ conn.zrangebyscore(Server.config.retry_namespace, 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)
+ multi.incrby("#{Server.config.retry_namespace}:total", retries.count)
+ multi.zrem(Server.config.retry_namespace, retries)
+ multi.lpush(Server.config.queue_namespace, retries)
end
else
conn.unwatch
end
end